我需要一些帮助。我试图让函数从主要读取数组的正确长度。通过询问用户问题以获得是或否确定数组长度然后它相应地添加到列表中是用户输入是。我想我可能无法正确添加到列表中,默认为空。无论我回答什么问题,程序将始终输出完整列表。如果问题的答案是正确的,它应该只输出添加的元素。真的很感激这个thx的一些帮助
list1 = list()
def checkGolf():
if len(list1) == 5:
print("You are an expert golfer!")
elif len(list1) == 4:
print('You have some knowledge on golf')
elif len(list1) == 3:
print('You can hit the ball at least congradulation.')
else:
print('You have no idea why you are doing')
return;
driver = input('Are you using a golf Driver? (yes or no)')
feet_square = input('Are your feet square to the target? (yes or no)')
equal_distance = input('Is the ball an equal distance? (yes or no)')
transfer_weight = input('Did you transfer your weight smoothly from back foot to front foot? (yes or no)')
ball_hit = input('Did you turn your head to watch the ball after contact? (yes or no)')
if driver == ("yes") or ("Yes") or ("YES") or ("y"):
list1.append("used driver")
else:
print('Error unknown input run program again')
if feet_square == ("yes") or ("Yes") or ("YES") or ("y"):
list1.append("feet are square")
else:
print('Error unknown input run program again')
if equal_distance == ("yes") or ("Yes") or ("YES") or ("y"):
list1.append("ball is equal distance")
else:
print('Error unknown input run program again')
if transfer_weight == ("yes") or ("Yes") or ("YES") or ("y"):
list1.append("transfered weight")
else:
print('Error unknown input run program again')
if ball_hit == ("yes") or ("Yes") or ("YES") or ("y"):
list1.append("watched ball after hit")
else:
print('Error unknown input run program again')
print('Here are your current skills in golf')
for st in list1:
print(st)
checkGolf()