+ 2
i can't read and understand this question
4 Answers
+ 4
1- Do not name your list using the name <<list>> because any variable inside brackets is a list. It may confuse the interpreter.
2- a shortcut for <<else>> statement
def calc(mylist):
if len(mylist)==0:
return 0
else:
return sum(mylist)
# <<sum>> is a built-in python function
list = [1, 3, 4, 2, 5]
x = calc(list)
print(x)
Overall, you nailed it because I can clearly see that you figured out your own personal solution and you worked out your brain. This is the main point, <<Brain Workout>>
Keep going đđ
+ 2
Per Bratthammar
True. <<list>> is not a reserved keyword. My bad.
Thank you for the refresher đ
0
#Hi iTech !
I can't see how the code I showed previously, works
This code is supposed to add individuals instant of the list but after 'else' I can't figure out how it works.
Your answer is much easier to understand but I need to understand the original phrase