high-low part 3

Change hilo.py so that it picks a random number between 1 and 5:

>>> %Run hilo.py
Pick a number: 3
Wrong! The computer's number was 4
>>> %Run hilo.py
Pick a number: 2
You got it right!

The actual game uses random numbers between 1 and 100, but we’ll just do between 1 and 5 for now.

Show solution

import random
computer_number = random.randint(1, 5)
guess = int(input("Pick a number: "))
if guess == computer_number:
    print("You got it right!")
    print("Wrong! The computer's number was", computer_number)

previous: the random module next: while loops