Today I have been learning a "for loop" in Python. I type the code in Python Shell and SyntaxError: invalid syntax appears after the function print("I finished") with the word print in red.
words = ["cat", "125", "dog", "pig"]
for word in words:
if word == "125":
print("No spam please!")
break
print("Nice " + word)
else:
print("I am lucky: No spam.")
print("I finished")
But when I write the code in Notepad and save as *.py and than run with Command Prompt it works correctly and comes:
Nice cat
No spam please!
I finished
What is with the third "print" function wrong?