< prev | index | next >

Loops!

from random import randint

while True:
    answer = randint(1, 100)
    guess = int(input('Guess a number between 1 and 100: '))

    if guess == answer:
        print('You win!')
    else:
        print('You lose!')
from random import randint

while input('Play game? y/n: ') == 'y':
    answer = randint(1, 100)
    guess = int(input('Guess a number between 1 and 100: '))

    if guess == answer:
        print('You win!')
    else:
        print('You lose!')

< prev | index | next >