Search code examples
python-2.7pycharmpep8

PyCharm shows "PEP8: expected 2 blank lines, found 1"


Consider the following code:

def add_function(a, b):
    c = str(a) + b
    print "c is %s" % c

def add_int_function(c, d):
    e = c + d
    print "the vaule of e is %d" % e

if __name__ =="__main__":
    add_function(59906, 'kugrt5')
    add_int_function(1, 2)

It always shows me: "expected 2 blank lines ,found 1" in aadd_int_function, but not in the add_function.

When I add two spaces in front of the def add_int_function(c, d): there is a error shows unindent does not match any outer indentation level in the end of add_function:

enter image description here

enter image description here


Solution

  • Just add another line between your function definitions :

    1 line :

    enter image description here

    2 lines:

    enter image description here