a = [1, 3, 5, 10, 12]
a = [31]
Can you add numbers in the same list like that?
python
I think you want this.
a = [1,2,3,4,52,345,3215,12345,1]
b = sum(a)
print(b)
>> 15968
I think it would have been easier to understand if it was "getting the sum of the elements in the list" than "add the numbers in the list." From now on, we recommend adding explanations so that third parties can clearly see exactly what they want from the desired outcome.
# example list
a = [1, 3, 5, 10, 12]
# desired outcome
31
# Description
31 is the sum of the list elements.
© 2024 OneMinuteCode. All rights reserved.