Створіть і виведіть список який утворюється методом додавання двох (створенних вами) і помножених на 3 Пайтон
Ответы на вопрос
Ответил wherethefux
0
list1 = [1, 2, 3, 4, 5]
list2 = [6, 7, 8, 9, 10]
list3 = [list1[i] + list2[i] for i in range(len(list1))]
list4 = [list3[i] * 3 for i in range(len(list3))]
print(list4)
Ответил p15
0
Ответ:
Вариант 1
list1 = [1, 2, 3, 4, 5]
list2 = [6, 7, 8, 9, 10]
list3 = [(list1[i]+list2[i])*3 for i in range(len(list1))]
print(list3)
Вариант 2 (работает чуть быстрее наверное :) )
list1 = [1, 2, 3, 4, 5]
list2 = [6, 7, 8, 9, 10]
list3=list(map(lambda x, y: 3*(x + y), list1, list2))
print(list3)
Объяснение:
Новые вопросы