2021-07-30

My python virus generation code has an issue

I am trying to write a code that will count how many viruses there are after some time. Specifically, the original virus will begin to multiply after 120 sec, then every 60 sec, and it's 'offspring' follow the same pattern. With this, I am trying to find how many viruses there are after 879 seconds. The code below should execute every one second, and count how many times it executes until it reaches 879 seconds, but I keep getting an error. Can anyone help? Thanks

import time

maxtime = 10 

Arr = []

def virus():
    virus_count = 0
    count_time = 0
    time.sleep(1)
    while True:
        virus_count += 1
        count_time +=1
    if count_time > maxtime:
        Arr.append(count)
        print('There are', Arr, 'viruses')
        
while True:
    virus()
    
virus()


from Recent Questions - Stack Overflow https://ift.tt/3zJQvdq
https://ift.tt/eA8V8J

No comments:

Post a Comment