Menu
Coddy logo textTech

What To Buy

Part of the Fundamentals section of Coddy's Python journey — lesson 77 of 77.

challenge icon

Challenge

Medium

Write a program that receives three inputs (given):

  1.  A list of prices
  2. A list of item names
  3. A budget per item

 

The program should print:

  1. A list of items that you can afford within your budget
  2. How much budget would you need if you bought all of the affordable items
  3. How many items you couldn't afford

Check the test cases for the output format

Try it yourself

prices = input().split(",")
for i in range(len(prices)):
    prices[i] = int(prices[i])
items = input().split(",")
budget_per_item = int(input())

affordable_items = []
cant_afford = 0
total_needed = 0


# Write your code below




print("Can buy:", affordable_items)
print("Total budget needed:", total_needed)
print("Can't afford:", cant_afford)

All lessons in Fundamentals