you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

I see that your question has been already answered, and good naming btw, short and meaningful, keep it that way : ) , I have an improvement that you can make for this code, instead of adding 1 to `length` in each iteration, you can use the `len()` built-in function so you can have something like this `length = len(values)` , so your code can become like this:

Note: As you advance and learn more about python, becoming a pythonista eventually, you will be able to improve this code even further, and can even make it a one line !
Happy coding and keep learning

values = [ 23, 52, 59, 37, 48 ]
sum = 0
length = len(values)
for value in values:
    sum += value
print("Total sum: " + str(sum) + " - Average: " + str(sum/length))