Comp Sci 2026 Computer Science 2026

Assignment: Simple Shop

Due 11/18 at 11:59pm

In early computer RPGs like Rogue, inventory systems allowed players to collect and manage items during gameplay. In this project, you will write a program where you visit a shop and buy items.

Ever heard of a “Roguelike” game? These games get their name from the 1980 game Rogue, which let players explore dungeons, collect items, and manage their inventory. Roguelikes are known for features like permadeath, random item drops, and challenging gameplay, and many modern games are inspired by this classic genre.

Your program must meet the following specifications:

For example:

Welcome to the shop! You have 100 gold.

=== SHOP INVENTORY ===
- sword
- shield
- boots
- helmet

Pick an item (or type 'exit'): sword
Price: 50 gold
Buy this item? (yes/no): yes
You bought the sword!

You now have 50 gold.

Pick an item (or type 'exit'): shield
Price: 30 gold
Buy this item? (yes/no): no

Pick an item (or type 'exit'): boots
Price: 20 gold
Buy this item? (yes/no): yes
You bought the boots!

You now have 30 gold.

Pick an item (or type 'exit'): exit

=== PERSONAL INVENTORY ===
- sword
- boots

Total spent: 70 gold
Gold remaining: 30 gold

Working With Lists

You can find the index of an item in a list by using the index() method.

Example Code

# Item names and their prices
item_names = ["sword", "shield", "boots", "helmet"]
item_prices = [50, 30, 20, 25]

# Player inventory and gold
inventory = []
gold = 100

print("Welcome to the shop! You have 100 gold.")
print(f"Available items: {', '.join(item_names)}")

while True:
    print()
    choice = input(f"Pick an item (or type 'exit'): ").lower()
    
    if choice == "exit":
        break
    
    # TODO: Allow user to buy items if they have gold for it

# TODO: Print final inventory with total spent and remaining gold
Additional Challenges (not required)

When you’re happy with your program, upload the .py file to ThinkWave.