Aug-02-2019, 03:37 PM
(This post was last modified: Aug-02-2019, 03:37 PM by kasper1903.)
Hi guys.
I am quite new to the whole coding, and hope you could help me with this little piece.
I have this small script, which allows me to open random sites in my browser with 5 - 20 seconds interval.
I want to have a while loop, so it stops after it have repeated it for 5 times. But it wont work - Is it because I should use a for loop ?
Here is the code.
I am quite new to the whole coding, and hope you could help me with this little piece.
I have this small script, which allows me to open random sites in my browser with 5 - 20 seconds interval.
I want to have a while loop, so it stops after it have repeated it for 5 times. But it wont work - Is it because I should use a for loop ?
Here is the code.
import webbrowser import time import random repeat = 4 while repeat < 4: sites = random.choice(['google.com', 'youtube.com']) visit = "http://{}".format(sites) webbrowser.open(visit) seconds = random.randrange(5, 20) time.sleep(seconds) repeat += 1 repeat = repeat + 1Thank you! :)