Login Validator
Beginner · Write the code · from Python If-Else: Conditions, Elif, Nested Ifs, and Ternary
From the lesson: Python If-Else: Conditions, Elif, Nested Ifs, and Ternary
Every day you make hundreds of decisions. If it's raining, you grab an umbrella. If the traffic light is red, you stop. If your phone battery is below 20%, you look for a charger. These are all conditional decisions - you check something and act based on the result.
Read the lessonWrite a login validator. Two variables are given: username and password.
Rules:
"admin" and password is "secret123", print "Welcome, admin!""admin" but password is wrong, print "Wrong password""User not found"Expected output for username = "admin", password = "wrong":
Wrong passwordusername = 'admin'
password = 'wrong'
# Write the login validation logic
More if else exercises
- Even or OddBeginner
- Temperature AdvisorBeginner
- Predict the OutputBeginner
- Fix the Grade CalculatorBeginner
- Ternary Ticket PriceBeginner
All Python exercises · 50 practice problems · Control Flow quiz