I have the following piece of code asking for a certain input in a larger program:
elif user_input == "s":
input_sequence = input("Please enter a three letter sequence: ")
if len(input_sequence) == 3 and user_input.isalpha():
letter1 = input_sequence[0]
letter2 = input_sequence[1]
letter3 = input_sequence[2]
segment_sequence(corpus, letter1, letter2, letter3)
else:
print("\nERROR: please enter a three letter sequence\n")
However when I use the conditional statements, if an invalid input is entered I return back to my main while loop. How would I be able to go from an invalid input back to this same piece of code?
Apologies for any potential confusion in terminology as I'm new to programming.
Many thanks
Aucun commentaire:
Enregistrer un commentaire