I've been trying to get this piece of code to work:
last_bits_repeat= "yes"
while last_bits_repeat== "yes":
try:
another_number_repeat= input("do you have another number to add??")
another_number_repeat= str(another_number_repeat)
except TypeError as e:
if not repeat:
print("You left this empty, please write something!")
last_bits_repeat= "yes"
else:
print("This is not empty, but invalid")
It doesn't work and I think its because of TypeError
.
My question is which exception should I use to validate the string? The user should input either "yes" or "no".