'This code is directly from a textbook for Cisco Devnet yet presents a syntax error in python 3.8.1 shell. Why? I tried viewing text in notepad++

while True: string = input('Enter some text to print. \nType "done" to quit>') if string == 'done': break print(string) print('Done!')

SyntaxError: invalid syntax image of issue

Image after idz's suggestion



Solution 1:[1]

I think your problem is that you wrote:

while true:

instead of

while True:

However, if you are using Python 2 you should be aware that input will attempt to evaluate what you type in as Python. Depending on what your aim is, you may want to use raw_input instead. This is not an issue if your are using Python 3.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 idz