6.00 introuduction to computing problem set 1, question 3 . Hey there , i have been working on the thrid problem . after a while i checked the answer. i am reading through it just now . one thing that i am confused about is the true statements in the while loop. the balance = original balance . but the balance changes inside the for loop . would this not exit the while loop ?. Or does anything that happens inside the for loop not effect the while loop ?
could you please link to the solution you are referring to?
i have attached the solotion below
the `while` loop condition is `while True`, so you cannot exit that loop unless you break out of it, return, or throw an error
`True` is always true
you can write a program as follows to convince yourself that `while True` will create an infinite loop: ``` i = 0 while True: print i i += 1 ``` just be prepared to force quit the program
Ah ok i think i a understand , thanks for that . originally i thought the while true related to the first and and the second lines always being true . This was confusing me as the balancing was changing , meaning it was not true. But i see now that its not related at all. So essentially the while true is an infinite loop that will excute until it encounters a break. I get it now , thanks for your help
you got it :) welcome!
Join our real-time social learning platform and learn together with your friends!