I'm doing an assignment and really need help with one aspect of it. I have created a menu function but I need to be able to restrict the user input to just integers but every time I try I'm unable to do so. Is someone able to advise how is best to do this? The code is below :)
def welcomeMessage():
print("""
Please enter the appropriate number:
1. Connect to server
2. write a file
3. Quit
""")
while True:
welcomeMessage()
selection = int(input("please enter an option from the list"))
if selection == 1:
import client
client.Main()
elif selection == 2:
import edit
edit.Main()
elif selection == 3:
input ("press the enter key to exit")
break