How to use nested if else statement in python

0 votes
Can someone help me with nested if-else statement in Python?

It will be even better if you tell me the syntax.
Nov 19, 2018 in Python by Jino
• 5,820 points

1 answer to this question.

0 votes

The working of nested if-else is similar to any other programming language. C, Java, etc

Here you can look at the implementation of it.

age = int(input("Enter age "))
if (age >= 20) and (age <=50) :
    print ("Hello adult")
elif age > 50 :
    print ("Hello grandpa")
else :
    print ("Hello kid")
answered Nov 19, 2018 by Nabarupa

Related Questions In Python

+1 vote
2 answers

How to use the pass statement in Python

In Python programming, pass is a null statement. The ...READ MORE

answered Apr 5, 2019 in Python by anonymous
0 votes
5 answers

how to exit a python script in an if statement

Instead of using the normal UTF-8 encoding, ...READ MORE

answered Jul 4, 2023 in Python by bodymist
• 140 points
0 votes
1 answer

How do I use urllib to see if a website is 404 or 200 in Python?

For Python 3, try doing this: import urllib.request, ...READ MORE

answered Nov 29, 2018 in Python by Nymeria
• 3,560 points

edited Dec 11, 2018 by Nymeria 13,605 views
0 votes
2 answers

How to use threading in Python?

 Thread is the smallest unit of processing that ...READ MORE

answered Apr 6, 2019 in Python by anonymous
0 votes
1 answer

How to write inline if statement for print in Python?

Inline if-else expression must always contain the else ...READ MORE

answered Dec 4, 2018 in Python by Nymeria
• 3,560 points

edited Dec 6, 2018 by Nymeria 16,531 views
0 votes
1 answer

what is an else if statement in python?

if condition:    statement elif condition:     statement #this is how you use ...READ MORE

answered Mar 15, 2019 in Python by Waseem
• 4,540 points
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,183 views
0 votes
3 answers

how to use print statement in python3?

Brackets are required to print the output. >>> ...READ MORE

answered Nov 25, 2021 in Python by anonymous
+4 votes
7 answers
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP