How do i sum the output of an iteration in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do i sum the output of an iteration in Python

for example for x in range(0,20): print(x) please how do i get the sum of the output

28th Jul 2019, 10:51 PM
Primidac
Primidac - avatar
4 Answers
+ 3
x=sum(range(0,20)) print(x)
28th Jul 2019, 11:49 PM
Steven M
Steven M - avatar
+ 3
Quickest way, using this example: print(sum(range(0,20)))
29th Jul 2019, 1:52 AM
Kevin
Kevin - avatar
0
Thanks worked...
28th Jul 2019, 11:24 PM
Primidac
Primidac - avatar
0
Thanks all
29th Jul 2019, 6:12 AM
Primidac
Primidac - avatar