This is a piece of code I made which works as expected except for the else branch. I have to type in a response without y 3 times to successfully go into that branch. Does anyone understand why that is happening?
def marker_question(position, marker_position): invalid_input = True while invalid_input: write("Would you like to do anything with the marker?") answer = input().lower().strip() if "y" in answer: write("Would you like to pick it up and place it or would you like to teleport to it?") answer = input().lower().strip() if "pick" in answer or "place" in answer: marker_position = position invalid_input = False elif "teleport" in answer: position = marker_position invalid_input = False else: write("That is not a possible action") else: write("You have decided to do nothing with the marker") invalid_input = False return position, marker_position 

y2 times.elsebranches in this code. Which are you referring to?write()?