0

Map problem on Intermediate Python

This code is used to calculate the sum between salaries and bonuses. I get the correct amounts, however, I don’t know how to make it so it prints out a list at the end instead of each individual elements amounts. salaries = [2000, 1800, 3100, 4400, 1500] bonus = int(input()) for i in salaries: print(i + bonus)

27th Jan 2022, 3:48 AM
Quality Crew
Quality Crew - avatar
2 Answers
+ 5
You can declare an empty list and add each updated price to that list using append() method. Or you can use map() instead of for loop.
27th Jan 2022, 3:58 AM
Simba
Simba - avatar
+ 2
print(*[s+bonus for s in salaries])
27th Jan 2022, 7:30 AM
Oma Falk
Oma Falk - avatar