Skip to content
Sign upLog in
← Back to Community

Need help

Profile icon
Bobo48

I need to make it so a generates a random number each time instead of printing out the same random number multiple times.

Voters
Profile icon
Bobo48
Comments
hotnewtop
Profile icon
ash15khng

Just do something like:

import random for i in range(10): print(random.randint(1,100))
Profile icon
Geocube101

change the value of a by putting

a = random.randint(1, 100)

inside the loop

Profile icon
Bobo48

@Geocube101
Still doesn't fix the problem :/ It still only prints the same number 9 times instead of 9 different random numbers each time

Profile icon
Geocube101

@Bobo48
If you're printing in the while loop then the code snippet above should also be in the while loop
Try placing the code snippet mentioned above inside the while loop

Profile icon
Bobo48

@Geocube101
Can't do that because I need it to add another_thingy along with other things as this is an inventory system and I can't make 500 different versions for each combination of items.

Profile icon
Geocube101

@Bobo48
What exactly are you trying to do?
As i understand it, you need to change the value of a in the while loop so it prints out a different number every time but can't?

Profile icon
Bobo48

@Geocube101
basically I need the for loop to work AND the while loop to print different random numbers each time. Sorry for the late response