Ask coding questions

← Back to all posts
How to do IF statements?
madmonster (32)

I learnt python from a book which is outdated. It was a book published in 2013 and its IF statements that don't work.

abc3354 (227)

I don't think that the if statements changes between python version however :

#Simple if/else
if condition:
    print("do something")
    print("do something else")
# You must use always the same indentation

print("do something in one line") if condition

You may find a beginner course if you course is outdated, you can find online courses.
Maybe someone else knows a good course ?

Replit helper here !
If you found my answer helpful, you can upvote :)

AllAwesome497 (397)

Here is pythons tutorial:

if _______:
#Indention is how it tracks what’s in the if statement
18staleyn (0)

I would also suggest trying code academy. You may have to slug through stuff you already know how to do, but it may give you refreshers or teach you a few things you didnt realize you could do or things you forgot how to do, as well as teaching you new things.