-2
class Employee:

def displayEmployee(self):

   a=120

   print a

emp1 = Employee()

print (emp1.displayEmployee())

i am also getting 120 None

i want to remove none from my output

Ateek
  • 5
  • 2
  • Your indentation got messed up pasting into the question, but I bet the problem is here ` print a`. Note there is an extra space. Python is picky about indentation. All you need to do is remove the space. – Paul Rooney Jan 06 '17 at 04:38
  • 1
    What's unclear about that error message? It even tells you which line to look at. – Kevin J. Chase Jan 06 '17 at 04:58
  • Possible duplicate of [IndentationError: unindent does not match any outer indentation level](http://stackoverflow.com/questions/492387/indentationerror-unindent-does-not-match-any-outer-indentation-level) – Kevin J. Chase Jan 06 '17 at 04:58
  • Thank you so much Rooney I stuck two days for it. – Ateek Jan 06 '17 at 05:01
  • 1
    @ateek ask a new question rather than progressively adding new questions to the same post. That's one thing that don't half piss off answerers. The simple answer though is to remove the second print. Your function has no return statement and so returns `None`. That is what you are seeing. – Paul Rooney Jan 06 '17 at 05:26

1 Answers1

2

Your code is not formatted, but the error tells you that you have a wrong indentation. Your code should be:

class Employee:
    def displayEmployee(self):
        a=120
        print a

emp1 = Employee()
print (emp1.displayEmployee())

This will get you rid of the IndentationError, and presumably do what you want. However, the last line should be:

emp1.displayEmployee()

instead of print(...), because the displayEmployee method prints itself something, and does not return anything to print.

Right leg
  • 16,080
  • 7
  • 48
  • 81