Following The New Boston on youtube, he is using is in an if statement and doesnt show any error, on mine I get a syntax warning and it asks if I meant ==, but still displays the output the way it should be.

Have you tried the tutorials code verbatim?

Can you show the code in question?

def get_gender(sex='unknown'):
if sex is "m":
sex = 'Male'
elif sex is 'f':
sex = 'Female'
print(sex)
get_gender('m')
get_gender('f')
get_gender()

One thing to remember is that in python formatting matters. This site has a code editor to help you format your code. The button is titled Code Block and looks like this, </>.

def get_gender(sex='unknown'):
    if sex is "m":
        sex = 'Male'
    elif sex is 'f':
        sex = 'Female'
    print(sex)
get_gender('m')
get_gender('f')
get_gender()

That being said, do you have the link to the tutorial?

This code will always give you that warning. Basically:

is is for comparing whether 2 objects reference the same area in memory.

== is for comparing whether 2 objects hold the same value(s)

Did some more research on this. It appears the tutorial was written using python 3.4. The syntax warning is new with python 3.8. I would suggest that this is why the tutorial doesn't show a warning.

commented: Thank you very much!! +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.