Python IndentationError in executing my code -


i learning python. , trying write simple code this.

def isprime(n):     a=0     if n==1:         print("1 special")     x in range(1,n):         if n%x==0:         a=a+1        if a==2:         print("{} prime".format(n))     else:         print("{} not prime".format(n)) n in range(2,20):     isprime(n) 

then error states "indentationerror: expected indented block" @ line 7. what's error actually? can help? sorry if silly. new python.

your error lies in second if statement:

def isprime(n):     a=0     if n==1:         print("n special")     x in range(1,n):         if n%x==0:             a=a+1                #this line should indented             #can written as: a+=1     if a==2:         print("{} prime".format(n))     else:         print("{} not prime".format(n))  n in range(2,20):     isprime(n) 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -