Transform string to f-string
How do I transform a classic string to an f-string ? : variable = 42 user_input = "The answer is {variable}" print(user_input) The answer is {variable} f_user_input = # Here the operation to go from a string to an f-string print(f_user_input) The answer is 42 An f-string is syntax , not an object type. You can't convert an arbitrary string to that syntax, the syntax creates a string object, not the other way around. I'm assuming you want to use user_input as a template, so just use the str.format() method on the user_input object: variable = 42 user_input = "The answer is {variable}" formatted