Hello,
May i know why object 'c' does not prompt for employee name and employee id in
the following code
i get out put as
Enter employee name:john
Enter employee id:56
Employee name is: john
Employee id is: 56
----------------------------------------------------
Employee name is: test
Employee id is: 1003
----------------------------------------------------
Employee name is: john
Employee id is: 56
class employee:
emp_name=""
emp_id=0
def collect_name():
return(input("Enter employee name:"))
def collect_id():
return(input("Enter employee id:"))
def show(self):
print("Employee name is:",self.emp_name)
print("Employee id is:",self.emp_id)
def __init__(self,name=collect_name(),id=collect_id()):
self.emp_name=name
self.emp_id=id
a=employee()
a.show()
print("----------------------------------------------------")
b=employee("test",1003)
b.show()
print("----------------------------------------------------")
c=employee()
c.show()
Thanks & BR,
Bharath Shetty
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor