The code given below accepts a list of numbers as an argument and returns the sum of all even numbers from the list. Observe the following code carefully and rewrite it after removing all syntax and logical errors. Underline all the corrections made.
def sum_even(lst)
sum=0
for i in range(length(lst)):
if lst[i]%2=0:
sum=sum+lst[i]
return (sum)
Answer:
Answer by student
def
sum_even
(lst)
:
sum=
0
for
i
in
range(
len(lst)
):
if
lst[i]%
2
==
0
:
sum=sum+lst[i]
return (sum)
Detailed answer by teachoo
The rest of the post is locked. Join Teachoo Black to see the full post.