Welcome to the Treehouse Community
Looking to learn something new?
Hrithik Sharma6,090 Points
Why the while loop is not working in python?
Function alone works fine but when put it in while it doesn't work do anyone know What's the problem Code:-
import webbrowser import time i = 0 def startBrowser(seconds, url): time.sleep(seconds) webbrowser.open_new(url) while i == 2: startBrowser(10, "www.google.com") i += 1
Steven Parker215,960 Points
The "while" condition is checking to see if "i" is equal to 2. Since "i" starts out set to 0, this condition is not true so the loop never runs.
Perhaps you meant to write: "
while i < 2:" instead?