Let's create a secret word game with python to understand the use of "if and while statements"!
Netsai
Posted on June 9, 2023
secret_word = "Whileloop"
guess =""
guess_count = 0
guess_limit = 3
out_of_guesses = False
while guess != secret_word and not out_of_guesses:
if guess_count < guess_limit:
guess = input("Enter your word: ")
guess_count += 1
else:
out_of_guesses = True
if out_of_guesses:
print("out of Guesses, You looooooose the game π« ")
else:
print("You winππ")
π πͺ π
π©
Netsai
Posted on June 9, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
python How to Build Your First Python Game: A Step-by-Step Guide to Creating a Simple Shooter with PyGame
September 22, 2024