|
1- HW 2.4: what is wrong with this code? Does it matter that I use 'return' instead of print in this exercise?
2- HW 2.6: What does "while True" in the code bellow mean? in other word, what value are we testing if it stays 'True' ?
I appreciate any help... |
|
First Question: Second Question:
Means it's an infinite loop because the condition is always True :-) So.. when does it end? In such cases you have to use return or break statements. |
|
To expand on @mediomelon 's answer, any expression we test in a while loop's condition will evaluate to some boolean value, The loop will never end until you break out with a statement like |
|
HW 2.4 Yes, it does matter. It should print all output, including string
I.e. it should not be necessary for caller to use also
(This is actually incorrect usage of the HW 2.6 The |