I am trying to get user input as an integer in my program with the following code:
while True:
x = input("Enter the integer: ")
try:
num = int(x)
except ValueError:
print("input should be an integer")
continue
break
If I run it repeats "Enter the integer" "Enter the integer" "Enter the integer" "Enter the integer" and so on even though I am not typing anything into the keyboard
I have already closed the serial port through pySerial so I don't think I am getting input from an external device.
Is there a problem in the way I have written this code?
I am using the terminal JetBrains PyCharm Community Edition IDE with PySerial 2.7, Python 3.4 on Windows XP