0

def welcome_main_function():

print("Hello! This program will run all the ratings from a survey and return avereges or see what areas is in need of improvements")
print("Enter the word 'return avereges' to calculate the avereges of the survey results.")
print("Or enter the word 'improvement' to see what areas needs to be improved.")
user_input = input("Enter here: \n")

if user_input == "return avereges":
    sum_averege_func = response_values()
    print(sum_averege_func)
    avereges = get_averege_of_each_question(
        SHEET.worksheet('responses'))
    update_averege_worksheet(avereges)
    pass
elif user_input == "improvement":
    new_avereges = get_most_disliked_area(
        SHEET.worksheet('responses'))
    update_improve_worksheet(new_avereges)
    pass
return user_input

def validate_user_input(data_input): """ Validate user input, and keeps the program running until user enters correct value """

try:
    if data_input != "return avereges" or "improvement":
        print("string not correct")
except ValueError:
    print("check spelling")

data_input = welcome_main_function() validate_user_input(data_input)

  • i want the program to check either value, but when i run "improvement" it automatically prompts me to enter a new question and the error message is printed to the terminal. – Jacob Molsby Jun 13 '21 at 08:19
  • `if data_input != "return avereges" or data_input != "improvement":` – Yoshikage Kira Jun 13 '21 at 08:22
  • For now code is interpreted as `if (data_input!="return avereges") or ("improvement")` and a non-empty string (2nd block) is evaluated as True, always – azro Jun 13 '21 at 08:22
  • Oh that makes sense, thanks. But i still get prompted to enter a second question. do you think theres a problem with the if/elif statement in the first function ? – Jacob Molsby Jun 13 '21 at 08:34

0 Answers0