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,550 points
35 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 in Python by anonymous
48 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,310 points
831 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,500 points

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

How to use threading in Python?

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

answered Apr 6 in Python by anonymous
64 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,500 points

edited Dec 6, 2018 by Nymeria 648 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 in Python by Waseem
• 3,480 points
28 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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 133 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
30 views
+4 votes
7 answers