A nested if is an if statement that is the target of another if statement. Nested if statements mean an if statement inside another if statement.
if (condition1): # Executes when condition1 is true if (condition2): # Executes when condition2 is true # if Block is end here # if Block is end here
Program code:
Clear Doubts with Computer TutorIn case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in
Output:
Enter Phone number: 017-555-1212 Phone number is valid
Input a 12 digit phone number and check the 3rd and 7th index to validate presence of ‘-‘.
If the condition is satisfied, remaining places are checked to see if they are digits.
If these conditions are satisfied, phone number is valid, else it is invalid.
Basic python functionality is demonstrated in above program.
To view all the lessons in chapter 1: http://computertutor.in/class-12-computer-science/chapter-2/
To view entire class 12 computer science study material: http://computertutor.in/resources/
You cannot copy content of this page