0
def pchecker(n):
    i=2
    while i<n:
        if n/i==n//i:
            x=0
            break
    if x==0:
        print("composite")
    else:
        print("prime")
a=int(input("enter the no. to be checked"))
pchecker(a)

this is my code but it shows error

G:\python>python prime.py
  File "prime.py", line 3
    while i<n:
         ^
TabError: inconsistent use of tabs and spaces in indentation

i have never used tabs anywhere i put 4 spaces everywhere for indentation.i write my code in notepad++

Gaurav Kochar
  • 11
  • 1
  • 6
  • Maybe its in there... maybe its a different encoding like utf-8, utf-16 or code page and you have an odd space char. You could use python to open it in binary mode and check for `b'\t'`, any byte above `0x79` and any 0 byte. – tdelaney Apr 01 '18 at 06:07
  • 1
    I copied the same code into my Notepad ++ and I did not get this error - I'm running Python 3.6. – nj2237 Apr 01 '18 at 06:11

1 Answers1

0

I copied your code and it ran on my machine without problems. I don't use notepad++, so I don't know if there is any way how one could accidentally get tabs instead of spaces, but there is definitely nothing wrong with the code that you posted in your question. If you can't find what caused the tab that caused the error in your file, try pasting the code that you posted up here back into your file.

Alice Schwarze
  • 559
  • 7
  • 21