[Solved] How to convert a string to integer entered in input functon? [duplicate]


Just you can use int():

number=int(input('Enter a number? '))
print(number)

Otherwise, to be fool-proof, use try..except:

while True:
  try: 
    number=int(input("Enter a number ? "))
    break
  except ValueError:
    print("Please input a vaild number !!")

solved How to convert a string to integer entered in input functon? [duplicate]