Ask coding questions

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

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

Commentshotnewtop
abc3354 (113)

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

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

#Or
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 (247)

Here is pythons tutorial: https://docs.python.org/3/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.