IndentationError expected an indented block

后端 未结 5 1885
借酒劲吻你
借酒劲吻你 2020-12-05 18:30

Here is the code:

def myfirst_yoursecond(p,q):

a = p.find(" ")
b = q.find(" ")
str_p = p[0:a]
str_q = p[b+1:]

if str_p == str_q:
    res         


        
5条回答
  •  有刺的猬
    2020-12-05 19:28

    You've mixed tabs and spaces. This can lead to some confusing errors.

    I'd suggest using only tabs or only spaces for indentation.

    Using only spaces is generally the easier choice. Most editors have an option for automatically converting tabs to spaces. If your editor has this option, turn it on.


    As an aside, your code is more verbose than it needs to be. Instead of this:

    if str_p == str_q:
        result = True
    else:
        result = False
    return result
    

    Just do this:

    return str_p == str_q
    

    You also appear to have a bug on this line:

    str_q = p[b+1:]
    

    I'll leave you to figure out what the error is.

提交回复
热议问题