-1
var = 1
while var == 1:
    num = input("Enter a number :")
    print ("You entered: ",num)
    var = num
print("Good bye!")

Loop should continue after entering 1 but it's getting terminated after that.

Please someone suggest for this.

Weafs.py
  • 22,731
  • 9
  • 56
  • 78
Praveen Kumar
  • 53
  • 1
  • 9
  • Possible duplicate of [How can I read inputs as integers?](https://stackoverflow.com/questions/20449427/how-can-i-read-inputs-as-integers) – Praveen Kumar Dec 23 '17 at 20:10

2 Answers2

2

Did you try to cast it to integer? Like so:

num = int(input("Enter a number :"))

If this doesn't work you may try with booleans instead.

matox
  • 885
  • 11
  • 27
  • Here is similar problem: [http://stackoverflow.com/questions/20449427/input-integers-python](http://stackoverflow.com/questions/20449427/input-integers-python) – matox Oct 28 '14 at 06:39
0
  while True: 
     num=raw_input("enter number") 
     print float(num) 
Bosh
  • 8,138
  • 11
  • 51
  • 77