Skip to main content
Fix formatting and grammar. Edit tags.
Source Link
wjandrea
  • 34k
  • 10
  • 69
  • 105

How do I transform a classic stringstring to an f-string f-string? :

variable = 42 user_input = "The answer is {variable}" print(user_input) 

The answer is {variable}

Output: 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

Desired output: The answer is 42

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

How do I transform a classic string to an f-string?

variable = 42 user_input = "The answer is {variable}" print(user_input) 

Output: The answer is {variable}

f_user_input = # Here the operation to go from a string to an f-string print(f_user_input) 

Desired output: The answer is 42

Post Reopened by shad0w_wa1k3r, Aran-Fey, PM 2Ring, slfan, Mihai Chelaru
edited tags
Link
Chris_Rands
  • 41.7k
  • 15
  • 92
  • 126
Post Closed as "Not suitable for this site" by ItamarG3, class stacker, Dalin Huang, Brian Tompsett - 汤莱恩, CommunityBot
Source Link
François M.
  • 4.3k
  • 11
  • 36
  • 87

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