+ 1

what's the right order ? thanks ! anybody can help me?

Rearrange the code to define a function that calculates the sum of all numbers from 0 to its argument. def sum(x): res += i for i in range(x): return res res = 0 Unlock

7th Mar 2018, 4:46 AM
Kevin Zhao
Kevin Zhao - avatar
2 Answers
+ 1
def sum(x): res = 0 for i in range(x): res += i return res
26th May 2023, 9:33 AM
Keenan Naidoo