-4

This might be a stupid question but I keep getting this error: "inconsistent use of tabs and spaces in indentation" I already made sure over and over that the number of spaces and tabs are consistent but I can't get rid of this error.

def skip_elements(elements):
    i = 0
    for a in range(0,5):
        i+=1
    return i
Eric
  • 95
  • 2
  • 11

3 Answers3

0

I already made sure over and over that the number of spaces and tabs are consistent

The problem here is that you are indenting using both tabs and spaces throughout the file. You shouldn't be mixing them. Either indent with only spaces, no tabs, or vice versa.

Omnikar
  • 307
  • 2
  • 9
0

"inconsistent use of tabs and spaces" means you have a combination to tabs and spaces. A given Python file can should only be indented with either tabs or spaces, not both.

How to fix this depends on your editor. Ideally I would recommend configuring it so that all tabs are automatically converted to spaces (or vice versa)

QuinnFreedman
  • 2,242
  • 2
  • 25
  • 42
  • I'm still new to Python so I am open to trying out different editors. Which one would you recommend to solve this? – Eric Mar 21 '21 at 03:51
  • *"A given Python file can only be indented with either tabs or spaces, not both"* - Not true. – Manuel Mar 21 '21 at 03:52
  • "A given Python file can only be indented with either tabs or spaces, not both." - you can technically use both. It's a terrible idea, but you can do it. – user2357112 Mar 21 '21 at 03:57
  • Sublime Text 3 can perfectly solve this – Aryan Mar 21 '21 at 04:22
0

If you are using Jupyter notebook, Jupyter nbextensions Code Prettifier may be able to help.

Abhijith
  • 48
  • 4