I am creating a program that asks for the user's name, number, hourly pay rate, and shift, and stores all the values inside of two classes and print them again.
Here is my code:
class Employee(): # Set class that keeps data attributes of name & number
def __init__(self):
name = input("Name?: ")
self.name = name
number = input("Number?: ")
self.number = number
ProductionWorker.Shift(self)
class ProductionWorker(Employee):
def Pay(self):
pay = input("Pay?: ")
self.pay = pay
def Shift(self):
shift = input("Shift?: ")
self.shift = shift
if shift == 1:
self.shift = "day"
ProductionWorker.Pay(self)
elif shift == 2:
self.shift = "night"
ProductionWorker.Pay(self)
def result(): # Print results
userName = Employee()
userNumber = Employee()
userShift = ProductionWorker()
userPay = ProductionWorker()
print(userName.name)
print(userNumber.number)
print(userShift.shift)
print("$" + userPay.pay)
quit()
result()
What is the reason that this code causes a repeating loop when initiated?
This is the result:
Name?: John
Number?: 1234567
Shift?: 1
Name?: John..
Number?: 1234567
Shift?: again?
Name?: