I want to create a string, but include comments for each part. In Python, I can do this inside the function print
, but I can't do it if I'm creating a variable.
print("Hello " + # WORKS
"World!")
greeting = "Hello " + # FAILS
"World!"
print(greeting)
Throws the error:
File "space.py", line 4 greeting = "Hello " + # FAILS ^ SyntaxError: invalid syntax
I tried line continuation:
greeting = "Hello " + \# FAILS
"World!"
print(greeting)
File "line_continuation.py", line 4 greeting = "Hello " + \# FAILS ^ SyntaxError: unexpected character after line continuation character