DEV Community

Manan mangla
Manan mangla

Posted on

python-quiz game

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 1 to 5.
  • UX Timing: Instead of delaying before showing the question, I placed print(quiz[i]) above time.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

  1. Dictionary Slicing: I initially tried slicing the dictionary (quiz[1:1:5]) before realizing dictionaries require direct key indexing (quiz[i]).
  2. Loop Scope: My first draft placed input() outside the for loop, 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 break rule, 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)

Collapse
 
manan_mangla_ade63f658152 profile image
Manan mangla •

this is my first post on dev.to i hope if anyone see this gonna like it ๐Ÿ˜