when the user input -1 , not end , why this is happened?
user_input= int (input('enter your eage.-1 is end '))
ages=[]
while user_input > 0:
ages.append(user_input)
print(int(input('enter the next age')))
print('the ages are ', ages)
1 answers ( 0 marked as helpful)
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