Please answer why indentation error occur? And how to remove this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please answer why indentation error occur? And how to remove this?

val=int(input("enter value")) count=2 while count<=val: value=2;num=0 while value<=val and value<=count: if count%value==0: num+=1 value+=1 if num==2 : print(value,sep=",",end="") count=count+1

21st Mar 2020, 4:21 PM
Hammer
Hammer - avatar
5 Answers
+ 1
Your if statement is not matching with any outer while loop needed identation. Check these for how many spaces there need val=int(input("enter value")) count=2 value=2 num=0 while count<=val: while value<=val and value<=count: if count%value==0: num+=1 value+=1 if num==1: print(value,sep=",",end="") count=count+1
21st Mar 2020, 4:54 PM
Jayakrishna 🇮🇳
+ 1
Give a tab for the statements that you are writing inside a loop or any conditional statements or inside any functions... Then you won't get any IndentationError
22nd Mar 2020, 6:34 AM
sarada lakshmi
sarada lakshmi - avatar
0
Thanks
22nd Mar 2020, 10:34 AM
Hammer
Hammer - avatar
0
Thanks
22nd Mar 2020, 10:35 AM
Hammer
Hammer - avatar
0
In built python follows the indentation rule... No one can change it... One must follow the rule for effective programming
23rd Mar 2020, 10:12 AM
sarada lakshmi
sarada lakshmi - avatar