0

Sum list with mumber

It's possible in python sum the only element of list with a single number in this mode: list=list+k? Thanks

13th Sep 2019, 7:44 PM
Silvio Petix
Silvio Petix - avatar
6 Answers
+ 2
What's the expected output?
13th Sep 2019, 8:02 PM
Diego
Diego - avatar
+ 2
#do you want this: list = [10, 15, 30] k = 5 result += sum(list) + k print(result) #60 #or this: list = [10, 15, 30] k = 5 list.append(k) print(list) #[10, 15, 30, 5] or sth else?
13th Sep 2019, 8:06 PM
Anton Böhler
Anton Böhler - avatar
+ 1
intlist = [4, 7, 9, 1] k = 8 for i in range(len(intlist)): intlist[i] += k print(intlist) Output: [12, 15, 17, 9]
13th Sep 2019, 8:29 PM
Seb TheS
Seb TheS - avatar
0
List=[10, 15,30] K=5 List+=K It's possible this trick?
13th Sep 2019, 7:54 PM
Silvio Petix
Silvio Petix - avatar
0
Sum number at only element of list?
13th Sep 2019, 7:54 PM
Silvio Petix
Silvio Petix - avatar
0
Ok thanks
13th Sep 2019, 11:12 PM
Silvio Petix
Silvio Petix - avatar