Permalink
Cannot retrieve contributors at this time
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?
6A-python-story/graphics.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (23 sloc)
1.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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])) |