Home > Software design >  Why is infinite inputting of a variable happening in Python?
Why is infinite inputting of a variable happening in Python?

Time:10-05

num = int(input())
evenCounter = 0
while num != 0:
    if num % 2 == 0:
        evenCounter  = 1

print(evenCounter)

Maybe this is sort of silly question, but I really can't figure out why does inifite input of the variable happen here. The console just keep asking me to write in a number for some reason.

CodePudding user response:

I guess you get it wrong, it asks user input just once, and then it's stuck in a while loop, and you think that it's asking user anther input. To check it just add some text in input('add some text here: ' ) and you'll see that input is called just once.

  • Related