我试图解决这个问题,当我使用(def checkIn)函数时,它显示'str'对象没有'append'属性。我已经为petName=[]创建了一个列表,但它似乎无法追加输入。你知道吗
staffID = 'admin'
password = 'admin'
petType = ['Dog', 'Cat', 'Bird', 'Rodent']
petName = []
def loginFunction(s, p):
# Login inputs
staffID = input("Enter Staff ID: ")
password = input("Password: ")
loginTrust = False
while (loginTrust is False):
if (staffID == 'admin') and (password == 'admin'):
print("Successfully logged in")
loginTrust = True
else:
print("Wrong ID or Password. Please enter again. ")
loginTrust = False
staffID = input("Enter Staff ID: ")
password = input("Password: ")
def checkIn(petType, petName):
petName = str(input("Enter pet name: "))
petName.append(petName)
tempList.append(petName)
boardedPets.extend(tempList)
def FrontDeskMenu():
print("\nTaylor's Pet Hotel\nFront Desk Admin")
print("A. Check in pets")
print("B. Check out pets")
print("C. Payment")
print("D. Rooms Availability")
print("E. History")
print("F. Exit\n")
userInput = input("What would you like to do today?: ")
inputCheck = False
while (inputCheck is False):
if (userInput.lower() == 'a'):
checkIn(petType, petName)
inputCheck = True
elif (userInput.lower() == 'f'):
quit()
else:
print("Invalid value! Please try again.")
userInput = input("What would you like to do today?: ")
inputCheck = False
loginFunction(staffID, password)
FrontDeskMenu()
您已经声明了一个字符串并尝试使用string“append()”,它是一个方法,可以与list[]一起使用。对字符串使用不同的名称,如pet\u name、pet\u name1、petName。你也应该申报你的名单-圣殿骑士和寄宿宠物。你知道吗
那就这么做 def签入(petType,petName):
首先,您没有初始化petName=[]templast=[]boardedPets=[]并且您正在覆盖您的petName。你知道吗
代码看起来像,我希望它能正常工作
相关问题 更多 >
编程相关推荐