Python Forum
Error in loops, new to Python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Error in loops, new to Python (/thread-2890.html)

Pages: 1 2 3


RE: Error in loops, new to Python - smbx33 - Apr-25-2017

For question one, I feel most of those steps are unnecessary as you would get the same answer from some thing like:

list_ = [4.5,6,120.5,9,1,2]
s = sum(list_)
print((s/len(list_)))
I tried to convert the already existing code into a functioning one. Although I didn't know that tiny little tidbit about modifying list while iterating over it :)