So I'm just starting to learn Python through Code Academy. In the course, it teaches that using triple quotes (double or single) allows for, "multi-line" strings. In the compiler for their website, the following code was entered and it worked:
Using Multi-Line strings in Code Academy Python
As you can see, the code works perfectly fine when saved to a variable and being asked to print it. I decided to try this out on Visual Studio Code however, and now there is a SyntaxError
.
quote = """
My name is William Pak
and I like to play games
"""
print("quote)
Upon running this on Visual Studio Code, the following error shows up:
>>> & C:/Users/Willi/AppData/Local/Programs/Python/Python38-32/python.exe c:/Users/Willi/OneDrive/Documents/GitHub/BlockLetters/initials.py
File "<stdin>", line 1
& C:/Users/Willi/AppData/Local/Programs/Python/Python38-32/python.exe c:/Users/Willi/OneDrive/Documents/GitHub/BlockLetters/initials.py
^
SyntaxError: invalid syntax
Can somebody explain to me exactly what is happening and why it isn't even allowing me to do this on Visual Studio Code, but it allows for me to do it on Code Academy's compiler?
P.S (This is my first ever question on stack overflow so I apologize if my question isn't written or explained well enough for you to understand.)
If you remove the quotation mark in the last line your code works:
quote = """
My name is William Pak
and I like to play games
"""
print(quote)
output:
My name is William Pak
and I like to play games