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.

Indentation तय करता है कि कौन-सा else किस if का है। हर 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.