i know nothing about programming but started learning python yesterday, and have learned some basic things. my dad is a programmer and challenged me to write a program that would be like '20 Questions'. i started it using the few things i know, and i think the way i started would work, but i also think there is other better ways to do it. any ideas?
here is what i wrote. the finished 'game' would be really limited and would limit the users choice of word to maybe 30 different words.
# sectioned off to person place or thing # 9 other q's for each path # layout: # question1>option - yes>question2A>option - yes>question3A # - no>question3B # - no>question2B>option - yes>question3C # - no>question3D print(All the questions will require you to type either 'yes' or 'no'.") import time time.sleep(2) 1a = input("Are you ready? ") if 1a == "yes": print("Let's get started! First question:") b = input("? ") if b == "yes": 2a = input("Is it a thing? ") if 2a == "yes": 3a = input("Can it fit in a backpack? ") if 2a == "no": 3b = input("Is it bigger than a car? ") # pattern would continue-keeps 'branching' out if b == "no": 2b = input("Is it a place? ") if 2b == "yes": 3c = input("Can it fit in a backpack? ") if 2b == "no": 3d = input("Is it bigger than a car? ") # pattern would continue-keeps 'branching' out if 1a == "no": print("Ok. Take your time:)") time.sleep(3) repeat else: print("Invalid response. Remember not to use capital letters.") time. sleep(3) repeat
Edited by jpaulsen: n/a