Code is meant to run forever except for when index_input == "Q"
. My problem is because i convert to an integer on the next line, the code fails and recognises the 'Q' as an integer.
while True:
index_input = input("Enter index to insert element to list (enter Q to quit): ")
index_input_int = int(index_input)
if (index_input == "Q"):
print('Good bye!')
break
elif (index_input_int >= 6):
print('Index is too high')
elif (index_input_int <= -1Q):
print('Index is too low')
Expected result is that 'Q' will break the while loop.