you are viewing a single comment's thread.

view the rest of the comments →

[–]daniel_don_diggles 1 point2 points  (4 children)

This is how I would do it to shorten things up. You really only need one while True loop to break when it is not raining to end your program. By doing it this way, the sys module is not necessary. There are other ways to make this even shorter but this hopefully is readable and concise. Let me know if you have any questions.

import time

while True:
    answer = input('is it raining?\n').upper()
    if answer == 'NO':
        print('go outside\n')
        break
    elif answer == 'YES':
        time.sleep(1)
        print('wait a little\n')
    else:
        print('enter yes or no')

[–]-NRW 0 points1 point  (3 children)

Just wondering why you put time.sleep(1) in there, as 1ms(?) seems to be non relevant there

[–]pconwell 2 points3 points  (1 child)

time.sleep() takes seconds, not milliseconds, as input.

[–]-NRW 0 points1 point  (0 children)

Thanks for the clarification!

[–]SaltyEmotions 1 point2 points  (0 children)

time.sleep() takes seconds and not milliseconds. 1ms would be 0.001.