def sum(list):
sum = 0
for l in list:
sum = sum + l
return sum
mylist = [1,2,3,4,5]
print(sum(mylist))
Hint: Observe the name of (1) the function, (2) the parameter therein. def sum(list):
sum = 0
for l in list:
sum = sum + l
return sum
mylist = [1,2,3,4,5]
print(sum(mylist))
Hint: Observe the name of (1) the function, (2) the parameter therein.You're probably right that you shouldn't have reimplemented it though - knowing how to use the language and its standard library is a good indicator for real-word experience.
Furthermore, I tried hard to ignore the glaring similarities between this and Zed Shaw's "Learn Python the Hard Way" from the way the course is structured down to some expressions.
This would have been cool if it at least mentioned the course on the right side pane with the other recommendations.
One could argue that in a source meant to teach Python, it shouldn't use examples that don't follow best practices. I feel that as a resource to, from the page, "learn how to write code, the basics and see examples" that it doesn't really matter too much.