Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do I use the, "IF ELSE", function in Python 3?

+4 votes
asked Dec 18, 2020 by Charles Weaver (240 points)
I've tried searching it up, but all I would get is a tutorial on how to use the if else function in PYTHON. Without the 3.

1 Answer

+3 votes
answered Dec 18, 2020 by LiOS (6,420 points)
selected Dec 19, 2020 by Charles Weaver
 
Best answer
When reviewing tutorials of "Python", it's highly likely Python 3. There are differences between Python2 and Python3 but these vary dependent on level.

A quick identifier is use of print. print("Hello") is Python3 while print "Hello" is Python2.

To do a if else in Python3 is same in Python2.

if a < b:

   ....

else:

   ....
commented Dec 19, 2020 by Charles Weaver (240 points)
Thank you! I had struggled so much trying to figure it out. Thank you, again.
commented Mar 2, 2021 by popstar403 (750 points)
You can also use:
elif a > b:
    ...
Edit: Corrected syntax
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...