151k views
3 votes
Write a function (getStringData) that has a parameter (prompt). The function will ask the users to enter A, B or C. Appropriate message will be displayed if A, B or C is not entered and then ask the user to enter again. It will return only A, B or C. Make sure to convert all entry to Upper case. prompt will be used when users are asked to enter. (Python)

User Toidiu
by
7.7k points

1 Answer

5 votes

Answer:

def getStringData(prompt):

while True:

userInput = input(prompt)

if userInput.upper() in ["A", "B", "C"]:

return userInput.upper()

else:

print("Please enter either A, B, or C!")

User Chkn
by
7.2k points