Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python while loop guessing game

right_number= 4
guess_count = 0
guess_limit = 3
#while conditions:
while guess_count<guess_limit:
    guess=int(input("Guess a Number: "))
    guess_count += 1
    if guess == right_number:
        print(' You won.')
        break
else:
    print(" Sorry. You have reached maximum trying limit.")
 
PREVIOUS NEXT
Tagged: #python #loop #guessing #game
ADD COMMENT
Topic
Name
6+6 =