< prev | index | next >

Randomness and the Standard Library

from random import randint

answer = randint(1, 100)
guess_string = input('Guess a number between 1 and 100: ')
guess_integer = int(guess_string)

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

< prev | index | next >