0

very new to python so sorry for the silly question

I've created a user input interface

fn=input() 
#Where the user will input version32 for instance so effectively
fn=Version32

I've then imported a template word document using docx, which has been heavily modified based upon user input. I then want the file name output to be saved as "fn" or in this case Version32

output.save(r"C:\Users\XXX\XXX\XXX\'fn'.docx")

Where fn is a variable? Is this even possible, or am I barking up the wrong tree?

Kind Regards!!

0

1 Answer 1

2

IIUC, you can do this using f-string:

output.save(rf"C:\Users\XXX\XXX\XXX\{fn}.docx")
Sign up to request clarification or add additional context in comments.

2 Comments

Genius, embarrassing how long I spent on that any you fixed my code with one letter!
Glad I could help. You can mark this as the answer if it worked!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.