Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
def intCheck(Message): #checks if its an int that is inputted, if not the prints "Invalid Input". Will loop until valid
while True:
try:
inp = int(input(Message))
return inp
except ValueError:
print("Invalid Input")
def display(mainWriting,choices):
print(str(mainWriting) + "\n") #Print the main writing
for x in range(0,len(choices)):
print("Type " + str(x) + " to " + choices[x]) #prints all the choices and what to type to pick those choices
choice = -1
while len(choices) > 0:
choice = intCheck("") #to correctly input what choice the user made
if choice < 0 or choice > len(choices) - 1: #makes sure that the input is valid
print("Your input did not select anything, please choose again")
else:
break
return choice
if __name__ == "__main__":
choices = ["a","b","c"]
choice = display("some writing",choices) #testing it (not part of the final program, can be ignored)
print(str(choices[choice]))