Lesson 11 of 34

if లోపల if: Nested Conditions

8 min 30 XP

కొన్నిసార్లు మొదటి ప్రశ్నకు జవాబు వచ్చాకే రెండో ప్రశ్న అడగగలం. అప్పుడు ఒక if లోపల మరో if ను ఇంకో 4 spaces లోపలికి రాస్తాం.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

ఏ else ఏ if కి చెందుతుందో indentation నిర్ణయిస్తుంది. ప్రతి if, దాని else ఒకే వరుసలో ఉండాలి.

Challenge

+30 XP

ఒక సులభమైన login ప్రోగ్రామ్. input() తో ముందు username, తర్వాత password చదవండి. username "admin" కాకపోతే → Unknown user "admin" అయి, password "1234" అయితే → Welcome "admin" అయి, password తప్పయితే → Wrong password

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.