-1

can't run python script. error msg: TabError: inconsistent use of tabs and spaces in indentation already used 10 times autopep8 -i file.py

code:

def main():
    # read_pdf( "docs/3.pdf" )

    extanstions = {}

    for root, dirs, files in os.walk('X:\backup'):
        for _file in files:
            extension = os.path.splitext(_file)[1]
            extension = extension[1:]

            try:
                extanstions[extension] += 1
            except:
                extanstions[extension] = 1

            print(os.path.join(root, _file) + " >> " + extension)

        print(extanstions.keys())
    return 0


main()
khelwood
  • 55,782
  • 14
  • 81
  • 108
ncux
  • 49
  • 1
  • 2
  • 5

1 Answers1

0

If you use tabs and spaces crossed over in your code this error comes up. Just replace all spaces by a tab or all tabs by spaces. Then the error wont come up anymore.

I mean for the indents, not in generell xD

This error often comes up after copy pasting code from a website in combination with your code because the indents on the website might be spaces and in your code the indents are tabs.

Whoozy
  • 161
  • 17