This is what I'm working just a little yes/no question.
print("Hello")
print("I love you")
answer = input("Do you love me?")
if answer in ["yes"]:
print("Yey! I knew it! Thank You!")
if answer in ["no"]:
print("O-ok, I understand, no worries.")
while True:
try:
print("Please answer me.")
answer = input("Do you love me?")
except ValueError:
continue
if answer in ["yes", "no"]:
break
When I enter a valid answer it print what I want but also jumps into the loop asking again, if I answer again then it breaks. I don't understand why tho. When I enter an invalid answer it loops until it gets one right, when it gets one right it breaks but doesn't answer. Can someone please explain why?
Here is where I have been currently testing it: https://trinket.io/python/5a25117b84