When I am using print() to print the results of iteration of list of object instances i am also getting None along with the values

Viewed 12

Here if a use print i get None too after each iteration but if i don't use print() everything is fine

class Employee():
    new_id = 1
    def __init__(self):
        self.id = Employee.new_id
        Employee.new_id += 1

    def say_id(self):
        print("My id is {}.".format(self.id))

class Admin(Employee):
    def say_id(self):
        print("I am an admin.")

class Manager(Admin):
    def say_id(self):
        print("I am in charge!")

# Write your code below
e1 = Employee()
a1 = Admin()
m1 = Manager()
meeting = [e1,a1,m1]

if i write

for people in meeting:

print(people.say_id())

the ouptput is

My id is 1.

None

I am an admin.

None

I am in charge!

None

why am i getting "None" here

also None doesn't show up if i omit print()

i.e;

for people in meeting:

people.say_id()

0 Answers
Related