0
Please suggest the code for Adding of n numbers in python?
I want to send n numbers as input to a function and add them up.
1 Resposta
+ 4
you can use the built-in sum function and a list:
n = [x for x in range(1,11)] # creates list [1,2,3,...,10]
print(sum(n)) # prints the result of sum on n
also possible to change the [ ] brackets to ( ) so you get a tuple instead a list