I am writing a program for a game I am creating, and I need to get the following:
- A number chosen from a range, probably 1-100.
- That number printed, will be turned into a display for the user later.
- Have that number locked out of being chosen again.
Due to the line of events, I cannot simply get all of the numbers pre-selected, they need to be selected in real time.
from random import *
number = randint(1, 100)
This is what I started with, predictably, but I have nowhere to go.
I tried using the array module, but I could not figure out how to work it, I am not the best at programming.
I tried using the following:
from random import *
number = randint(1,100)
print(number)
numberstore = number
while numberstore == number:
number = randint(1,100)
print(number)
numberstore = number
I don’t know how to make this work though.
>Solution :
I think you’re wanting something like this.
from random import *
numberstore = []
while True:
number = randint(1,100)
if number not in numberstore:
numberstore.append(number)
print(number)