write a python program, where list 'L' passed as an
argument and sum of all
values which are ending
ending with 3 from a list.
fast please
Answers
Answered by
5
Answer:
Try to implement it
Explanation:
# Python program to find sum of elements in list
total = 0
# creating a list
l = [11, 5, 17, 18, 23]
# Iterate each element in list
# and add them in variale total
for ele in range(0, len(l)):
if(l.endswith("3"))
total = total + l[ele]
# printing total value
print("Sum of all elements in given list: ", total)
Answered by
0
Answer:
def sum3(l):
l1=[]
l2=[]
for i in l:
l1.append(f"{i}")
for i in range(len(l1)):
if l1[i][-1]=="3":
l2.append(int(l1[i]))
return sum(l2)
list1=eval(input("enter a value in list format"))
print(sum3(list1))
Explanation:
since the question asks us to give the list as an argument we should create a function.
Similar questions