Printing out all the numbers in a list if the sum of those numbers exceed 100. : <p>List of numbers nums and prints all the numbers from nums in order until the sum of the numbers printed exceeds 100. I need to rewrite the function using a while loop and <strong>I cannot use for, break or return.</strong><br>
if the sum of the numbers is less than or equal to 100 then all numbers in the list are printed.
Below includes my attempt of the question (which is wrong...), and the outputs I would like to achieve.
I would like to know your ideas on how you would try to solve the problem or your advice on the logic of my code.
Many thanks in advance :D  </p>

<pre><code>def print_hundred(nums):
""" Hundy club """
total = 0
index = 0

while index &lt; nums[len(nums)]:
    print(nums)
    total += nums[index]


else:
    if total &gt; 100:
        print(total)


print_hundred([1, 2, 3])    
print_hundred([100, -3, 4, 7])
print_hundred([101, -3, 4, 7])  



test1 (Because the sum of those numbers are still less than 100)
1
2
3

test2 (100 - 3 + 4 = 101, so the printing stops when it exceeds 100)
100
-3
4

test3 (Already exceeds 100)
101
</code></pre>
