简体   繁体   中英

IndentationError: expected an indented block in def

I know there are many questions on this subject but i can't really find solution. I get this error every time running code

def spy_game(nums):
    code = [0,0,7,'x']
    for num in nums:
        if num == code[0]:
            code.pop(0)

    return len(code) == 1

Every line is intended correctly IMO.

  File "C:/Users/Гио/PycharmProjects/python_course/Методы и функции/Задачи по работе с функциями.py", line 61
    def spy_game(nums):
    ^
IndentationError: expected an indented block

I believe the problem is that you have inconsistent tabs and spaces.

Make sure you use only one of the above.

I think you must go for a online code formatter such as https://www.tutorialspoint.com/online_python_formatter.htm

This will also show you the identation error if it actually exists in your code and then you can correct it.

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