osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python "Bad syntax"


?
Hi, I have a problem in continuing the function.
?
I'm a beginner, I'm learning from a textbook. I'm going to put the following examples from a textbook that displays "wrong syntax"
?
>>> for letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
? ? ? ? ? ? if letter in "AEIOU":
? ? ? ? ? ? ? ? print(letter, "is a vowel")
? ? ? ? ? ?else:
? ? ? ? ? ? ? ? ?print(letter, "is a consonant")
?
In this text, I will write a "wrong syntax" after confirming the "else" function. How is it possible? Using the Bad Version of Python? Please, please, thank you very much!
?
The same error is in the "break" function:
?
>>> while True:
? ? ? ? ? ? ? item = get_next_item()
? ? ? ? ? ? ? if not item:
? ? ? ? ? ? ? ? ? ?break
? ? ? ? ? ? ? process_item(item)
?
Here 'wrong syntax' occurs after the "break".
?
How is it possible? Bad version of Python? Which version to use?
?
Thank you for any advice and help!
?
--?
https://mail.python.org/mailman/listinfo/python-list <https://mail.python.org/mailman/listinfo/python-list>
?
?

?
?