- 1
Something I'm missing in this code.. How to sum the n number from the user
My code.. n = int (input("Enter the number:")) for x in range (1,n+1): print (sum(x))
4 Réponses
+ 1
sum =0
n = int (input("Enter the number:"))
for x in range (1,n+1):
sum += x
print (sum)
Pretty simple
Stay tuned
+ 2
print(sum(range(1,int(input("Number: "))+1)))
+ 1
It sums iterable like list and tuple so sum(1) or that will cause error
- 1
Got it bro.. Tuning 🔥🔥🔥🔥