Python "Bad syntax"
Phil Boutros
philb at philb.ca
Mon Feb 5 12:28:56 EST 2018
<darkorbitaknaentou at centrum.cz> <darkorbitaknaentou at centrum.cz> wrote:
>
> 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!
Which version of python are you using? That syntax for "print"
started in python 3 (since print became a function).
Try adding:
from __future__ import print_function
before your code if you're still using python 2.x
Phil
More information about the Python-list
mailing list