Aniruddh Aniruddh - 1 month ago 19
Python Question

Small python Project

I am learning python and using Udacity website for it. In one of the projects, I need to make a program which enables users to take a break in every 2 hours. Now I understood the while function but it's showing an error called

expected a indent block
. Please help me to resolve it.
Here is my code:

import webbrowser
import time

break_count=0
total_count=3
while(break_count<total_count):
time.sleep(10)
webbrowser.open("https://www.youtube.com/watch?v=jlY5I1Lbe9c")
break_count=break_count+1


what should I do to resolve the issue?

Answer

Note: Python does not have semicolons or brackets to show scope therefore this is shown by indentation (certain amount of spacing). You can use 4 spaces (tabs) or 2 spaces, just have your text editor settings changed. Everything should be inside your while loop indented. So I put the 3 lines below it inside the while loop assuming that is your intention.

import webbrowser
import time

break_count=0
total_count=3

while(break_count<total_count):
    time.sleep(10)
    webbrowser.open("https://www.youtube.com/watch?v=jlY5I1Lbe9c")
    break_count=break_count+1