0

I need some help here. Im trying to get the function to read from the main the correct length of the array. The array length is determined by asking the user questions in order to get a yes or no then it adds to the list accordingly is the user enters a yes. I think I may be having trouble adding properly to the list which is by default empty. No matter what I answer for the questions the program will always output a full list. It should only output the elements added if the answer to the question is correct. Would really appreciate some help on this 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()
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135

0 Answers0