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,660 points
128 views

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
115 views
0 votes
1 answer

how to exit a python script in an if statement

This works fine for me: while True: ...READ MORE

answered Sep 19, 2018 in Python by bug_seeker
• 15,390 points
19,548 views
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,540 points

edited Dec 11, 2018 by Nymeria 4,502 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
217 views
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,540 points

edited Dec 6, 2018 by Nymeria 5,806 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,530 points
78 views
+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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,054 views
0 votes
2 answers

how to use print statement in python3?

The print statement has been replaced with a print() ...READ MORE

answered Jul 16, 2018 in Python by Mrunal
• 680 points
131 views
+4 votes
7 answers