4.5. For: Sum of cubes
pole55 (199)

For the given integer N calculate the following sum: 1³ + 2³ + ... + N³

You are viewing a single comment. View All
Neil_Chaudhury (9)

OK, so the first thing you need to do is change
for e in range(n) to for e in range(1, n+1)
This way, you're starting from 1 and ending at n.
Also, the for loop where you are going through lst could be simplified to a sum(statement),
eg. total = sum(lst)
Hope this helped you,
Neil
Btw, I forked your real and applied the above changes. here is my link > https://repl.it/@Neil_Chaudhury/45-For-Sum-of-cubes