Step 1: Ask Your First Question โ
Welcome to your first big project! Over 4 steps you'll build a whole quiz show game. The best part: you never retype anything โ each step starts you off with what you built last time. ๐ฌ
Every quiz show starts with one question:
answer = input("What is the capital of France? ")
if answer == "Paris":
print("โ
Correct!")
else:
print("โ Nope, it was Paris.")
But there's a problem. If your player types paris or PARIS or
Paris, that if says WRONG. Rude! ๐ค
Two string tricks fix it:
answer = input("Capital of France? ")
answer = answer.lower().strip() # " PaRiS " โ "paris"
if answer == "paris":
print("โ
Correct!")
.lower()makes everything lowercase.strip()chops off spaces at the ends
Now compare against the lowercase answer and everybody's happy.
Your mission
- Ask one quiz question with
input() - Clean the answer up with
.lower() - Use
if/elseto print a "correct!" or "wrong" reaction
Make it a question you would ask. ๐ค
Your code
Press โถ Run to see what your code does!