Title: Building a Sudden-Death Quiz CLI Game in Python (And What I Learned About Dictionary Lookups)
Today, as part of my daily 20โ30 minute coding streak, I built a terminal-based Sudden-Death Quiz Game in Python. One wrong answer, and the loop breaks immediately.
๐ ๏ธ How It Works Under the Hood
-
Data Structure: I stored 5 questions (covering tech, gaming, and cinema) and their answers in two separate dictionaries mapped by keys
1to5. -
UX Timing: Instead of delaying before showing the question, I placed
print(quiz[i])abovetime.sleep(2)so the player reads the prompt while the timer builds tension. -
Clean Matching: Applied
.lower().strip()on both ends so capitalization doesn't ruin a right answer.
๐ Bugs I Caught Along the Way
-
Dictionary Slicing: I initially tried slicing the dictionary (
quiz[1:1:5]) before realizing dictionaries require direct key indexing (quiz[i]). -
Loop Scope: My first draft placed
input()outside theforloop, meaning it only asked one question instead of iterating through all five.
โ๏ธ Honest Progress Check (75/25 Split)
-
75% Me: Creating the questions, writing every line in VS Code, designing the sudden-death
breakrule, and fixing the timer UX. - 25% AI Mentorship: Getting hints on why dictionary slicing threw an error and spotting indentation placementโno copy-pasting solutions.
What is one small CLI project you built when learning Python dictionaries? Drop your thoughts below! ๐
here is the link to the code please watch it and review it thank you โค๏ธ
https://github.com/MANAN-FULLSTACK-DEV/PYTHON-BASICS-PRACTICE-AND-LEARNING/blob/main/quiz%20game.py__
Top comments (1)
this is my first post on dev.to i hope if anyone see this gonna like it ๐