Content Too Large
ABC 413Problem 3 of 50
EasyWhat to do
Given a list of item sizes and a bag's maximum capacity, check if the total size of all items fits in the bag. Return 'Yes' if the sum of items <= bag_size, 'No' otherwise.
Key Concepts
if-statements
basic math (addition)
input and output
Examples
Input:
items = [3, 1, 4, 1, 5], bag_size = 15
Output:
Yes
Input:
items = [3, 1, 4, 1, 5], bag_size = 5
Output:
No
Tips for Beginners
- Focus on understanding the logic, not memorizing syntax
- Use print statements to debug your code
- Don't worry about input parsing - the function handles that for you
- If stuck, try writing out your solution on paper first
Python Editor
Loading Python...