While loop execution problem

i have tried to execute while loop program in python. But it always shows indentation error.
i am attaching the photo of the program, Could anyone help to solve the issue.

Check after opening while loop check whether you have put the ‘:’ symbol
then check if you have correctly left tab space
if it is showing error just go to each line inside the loop -press home- backspace till left most-- and press tab
read_five_times = “No”
count = 0
while read_five_times == “No”:
print (“Reading workshop…”)
count = count + 1
if(count == 5):
read_five_times = “Yes”

print (“Good Job ! You understood the workshop.”)

Hello @jayanth.chekkala
But in first line there is syntax error
in “No”
SyntaxError: invalid character in identifier

@ykoffice6920 there is an indentation error in your code at line 4 add space before read_five_times and print statement.

Hi @ykoffice6920, after the if condition you must give proper tab space for the statement below the if condition.Since you haven’t given that space the error occured.
Try the code below:


It is an indentation error. In python code blocking is done using indentation. So you have to put spaced for the codes which is inside the if condition.


Please indent the code as per the instructions already provided in the training.

See where Ubuntu terminal is showing you the possible error. It shows that after the if statement it was expecting an indented block. In the code you wrote, you need to provide indentation to all the statements which fall under the if statement.

 if (count == 5):
     read_five_times = "Yes"

I assume you hvae already initialized your count variable and you are incrementing its value inside the while loop. Python is extremely specific about the indentions(spaces you provide before each statement).
Identation helps in identifying whether a statement belongs to a particular control( a function or if/else condition/while etc) or not .
so the code should be indented as;


This will print Reading\nReading\nReading\nReading\nReading\nGood

hi@ykoffice6920 you should give a tab space before “read_five_times=“yes”” as it is inside a conditional statements. Any statements inside a conditional or loops must be given a tab space before them writing.