How can i use f-string with a variable, not with a string literal?
I want to use f-string with my string variable, not with string defined with a string literal, "..." . here is my code name=["deep","mahesh","nirbhay"] user_input = r"certi_{element}" # this string i ask from user for element in name: print(f"{user_input}") This code gives output: certi_{element} certi_{element} certi_{element} But I want: certi_{deep} certi_{mahesh} certi_{nirbhay} how can I do this? f"..." strings are great when interpolating expression results into a literal , but you don't have a literal, you have a template string in a separate variable. You can use str.format() to apply