+ 2

i can't read and understand this question

https://code.sololearn.com/cg7101rWwZ2L/?ref=app

28th Dec 2022, 3:27 PM
Yasin Sharifi
Yasin Sharifi - avatar
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 👏👍
28th Dec 2022, 4:47 PM
iTech
iTech - avatar
+ 2
# Hi, iTech ! # You can use the following code to check up whether ’list’ # is a keyword in Python or not. import keyword print(keyword.iskeyword('list'))
28th Dec 2022, 9:54 PM
Per Bratthammar
Per Bratthammar - avatar
+ 2
Per Bratthammar True. <<list>> is not a reserved keyword. My bad. Thank you for the refresher 👍
28th Dec 2022, 11:48 PM
iTech
iTech - avatar
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
29th Dec 2022, 2:02 PM
Yasin Sharifi
Yasin Sharifi - avatar