简体   繁体   中英

Indentation error for python 2.7

def ispermute(str1, str2):
    d1 = {}
    d2 = {}
    for letter in str1:
        if letter not in d1:
            d1[letter] = 1
        else:
            d1[letter] += 1

    for letter in str2:
        if letter not in d2:
            d2[letter] = 1
        else:
            d2[letter] +=1

    if d1 != d2:
        return False
    return True

While running this I am getting error as:

File "2.py", line 16
    if d1 != d2:
               ^
IndentationError: unindent does not match any outer indentation level

Can someone suggest what is the issue? This code is made to check the permutation of two strings.

You have mixed tabs and spaces in your code. If you are usings Sublime Text (as stated in the comments) you can:

  1. Select all your text ( Ctrl + A )
  2. View -> Indentation -> Convert Indentation to Spaces

You can avoid the problem in the future by turning on "Indent Using Spaces" under the View -> Indentation tab.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM