0

The code has an exclamation mark in the third line. The variable was not define with it "!r". Why is running or executing?


name = 'Fred'
print(f"He said his name is {name}.")

print(f"He said his name is {name!r}")  # this line*


My_name_is = 'I said my name is Parker'
print(f'what did you say? {My_name_is!r}.')
 

Jerry Jeremiah
  • 9,045
  • 2
  • 23
  • 32
Alg2code
  • 3
  • 2
  • Maybe this can help you - https://stackoverflow.com/questions/38418070/what-does-r-do-in-str-and-repr – Daniel Hao Sep 25 '21 at 22:52
  • 1
    Does this answer your question? [What does !r do in str() and repr()?](https://stackoverflow.com/questions/38418070/what-does-r-do-in-str-and-repr) – Tranbi Sep 26 '21 at 13:08

0 Answers0