
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Python Codes, Looping, Creating a Guessing Game using Python wherein player is trap on the game up until the player finds out the special number
Typology: Cheat Sheet
1 / 1
This page cannot be seen from the preview
Don't miss anything!

print( """ +================================+ | Welcome to my game, muggle! | | Enter an integer number | | and guess what number I've | | picked for you. | | So, what is the secret number? | +================================+ """) secret_number = 777 guess = 0 c = 0 while guess != secret_number: guess = input("Enter your guess: ") if guess == "exit": break guess = int(guess) c += 1 if guess < secret_number: print("Ha ha! You're stuck in my loop!") print("wrong secret number") elif guess > secret_number: print("Ha ha! You're stuck in my loop!") print("wrong secret number") else: print("Well done, muggle! You are free now.") print("correct secret number")