jeudi 6 juin 2019

How can i have a random number tick continuously running while python completes other tasks? [duplicate]

This question already has an answer here:

I'm writing a program which randomly increases or decreases a variable every second, and i cant get the program to complete other tasks while it is generating these random numbers. how do i have it tick in the background while other tasks and modules are doing things are completed

ive tried using a module with my random number generator, and tried it before and after calling modules but whenever it will continue ticking and stop other modules

import random
random_tick = True
#random tick gen
while random_tick == True:
  time.sleep(5)
  demand_change = random.randint(-10,10)
  island_demand += demand_change
#want to use this and other modules while tick continuously occurs
main_screen()

i want to be able to fully use the modules and other such things while "island demand" continues to change instead the code keeps on changing island demand and wont let me call modules

Also sorry if my formatting is bad, just getting into this stack overflow thing




Aucun commentaire:

Enregistrer un commentaire