Question about classes and objects in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Question about classes and objects in python

How can I take an input from the user and make it the name of an object for a class. For instance I have a class named Employee to keep track of employees and I want the user to input the name of a new employee and make a new object for that employee

2nd Mar 2022, 1:25 AM
Billy Stanley
Billy Stanley - avatar
3 Answers
0
Sorry forgot to mention it takes 3 arguments ( except self) here is my code so far class Employee: def __init__(self, name, points,infraction): self.name = name self.points[] = points[] self.infraction[] = [] input = input("new employee or existing one") if input == new: x = input("employee name")
2nd Mar 2022, 1:44 AM
Billy Stanley
Billy Stanley - avatar
0
I will have them add info into the points and infraction lists later /as needed so would that be in a method in the class or a passed argument?
2nd Mar 2022, 2:13 AM
Billy Stanley
Billy Stanley - avatar
0
Ok thanks
2nd Mar 2022, 2:28 PM
Billy Stanley
Billy Stanley - avatar