import random
sum = 0
s = [str(random.randint(1,100)) for i in range(10)]
for i in s:
if i[len(i)-1] == "2" or i[len(i)-1] == "3":
sum += int(i)
print(s)
print(sum)
['30', '100', '23', '15', '50', '16', '74', '55', '72', '4']
95
m = [312,654,3,3,654,543,3213,654,86341]
summ = 0
for i in m:
if str(i)[-1] == "2" or str(i)[-1] == "3":
summ += i
print(summ)
import random
sum = 0
s = [str(random.randint(1,100)) for i in range(10)]
for i in s:
if i[len(i)-1] == "2" or i[len(i)-1] == "3":
sum += int(i)
print(s)
print(sum)
Вывод:['30', '100', '23', '15', '50', '16', '74', '55', '72', '4']
95
m = [312,654,3,3,654,543,3213,654,86341]
summ = 0
for i in m:
if str(i)[-1] == "2" or str(i)[-1] == "3":
summ += i
print(summ)