New course! Every coder should learn Generative AI!
Try a free lesson0
List of integers (let 1-10). Write code to add the integers and display the sum.(using loop)
2 Answers
+ 1
print(sum(range(1, 11)))
+ 1
a = range(1,10)
res = 0
for num in a:
res+=num
print(res)
===== result: =====
45