Skip to content
loading...

re: How to fix an Endless Loop in Python? VIEW POST

FULL DISCUSSION
 

Regarding the random numbers, you need to seed random with a changing number. Not seeding, or always seeding with the same number, will result in the same random numbers being produced.

So, the most common way around this is to use the current time to seed random.

import random
from datetime import datetime
random.seed(datetime.now())

(Disclaimer: While this is what I've used for years in Python, I double-checked the exact syntax like I always do. This version comes from this StackOverflow answer)

 
code of conduct - report abuse