0
How to find the total of 5 numbers using for and range?
2 Réponses
+ 2
sum(n for n in range (1, 6))
This is the most simple way, but involves generator expression.
For absolute beginner level you can do it imperative style
total = 0
for number in range(1, 6):
total += number
0
l=[]
for i in range (5):
l[i] = input("items : ")
Sum(l)