Skip to content

Putting it All Together

Created By: Sean Boerhout

Alright, now let's put our skills to the test with a quick challenge.

Write a program that lets the user pick a number between 1 and 100. The program will try to guess the number after you tell it whether it's too high or too low. If the player wins the game, they should also be able to play again. It should work something like this:

Here's a hint:

To allow your program to come up with a random number, import random in your code. Then, use randint() to get a random integer between some 2 numbers:

import random

random_number = random.randint(0, 10) # a random number between 0 and 10!

Try making it in your ide! You can even use this interactive console:


Can't figure it out? Here is the answer.


Back to top