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.