Last answered:

11 Nov 2022

Posted on:

10 Nov 2022


when the user input -1 , not end , why this is happened?

user_input= int (input('enter your eage.-1 is end '))
while user_input > 0:
    print(int(input('enter the next age')))
print('the ages are ', ages)
1 answers ( 0 marked as helpful)
Posted on:

11 Nov 2022


Hey Roqia,

Thank you for reaching out!

Please, study the change in line 5:
In your version of the code, line 5 prints out the message 'enter the next age' but doesn't change the value of variable user_input. Therefore, when you repeat the while-loop again, user_input would not be changed to -1 which it needs to in order to exit the loop.

Hope this helps!

Kind regards,
365 Hristina

Submit an answer