Question: I'm writing a python code that checks whether or not the input value is valid and then gives the user the option to enter another
I'm writing a python code that checks whether or not the input value is valid and then gives the user the option to enter another value. The code I've included doesn't say but the user is supposed to enter a value between 1 and 8. Once I have this part done I'll modify the code so that the inputted value prints out part of a .txt file. I'm having issues getting the program to run. Help?
def select_list(): choice = input("Please enter the number corresponding to the degree you wish to see: ") return choice
def printout(): select_list() if choice == 1: print("1") # the "1" will be replaced with the code needed to print the corresponding section of the .txt file elif choice == 2: print("2")
elif choice == 3: print("3")
elif choice == 4: print("4") elif choice == 5: print("5")
elif choice == 6: print("6") elif choice == 7: print("7")
elif choice == 8: print("8")
else: print("Incorrect entry.")
repeat()
def repeat(): userInput = input("Would you like to view another program?(enter Y or N) ") if userInput == Y: printout()
elif userInput == N: print("Have a good day!")
print("done")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
