WEIGHT_LIMIT = 100 COUNT_LIMIT = 4 wizard_inventory = [] def display_title():     print("The Wizard Inventory program")     print() def display_menu():     print("COMMAND MENU")     print("show - Show all items")     print("grab - Grab an item")     print("edit - Edit an item")     print("drop - Drop an item")     print("exit - Exit program")     print() def show(inventory):     print("Show inventory")     for i in inventory:         print(i[0], i[1], "(", i[2], ")lbs")     total = calculate_weight(inventory)     print("Total Weights is : ", total, "lbs")     print(" Weight limits of 100 lbs") def calculate_weight(inventory):     total = 0     for i in inventory:         print(i[2])         total = total + float(i[2])     return total def grab_item(inventory):     list = []     total = 0     if (len(inventory) < 4):         list.extend(get_new_item())         print(list)         total = calculate_weight(inventory)         total = total + float(list[2])         print(total)     if (total < 100):         inventory.append(list)     else:         print("weight exceeds limit of 100 lbs")         show(inventory) # create a function which adds new items def get_new_item():     New_Items = []     # store item in list     for i in range(3):         New_Items.append(input(f'Enter value at index {i}: '))     return New_Items def edit_item(inventory):     index = int(input("Enter the index of the item to de edited: "))     if (index > len(inventory)):         print("Wrong index,Try Again!")     else:         Newname = input("Enter the new name for the item: ")         print("Before edit : ", inventory[index])         inventory[index][0] = Newname         print("After edit : ", inventory[index]) def drop_item(inventory):     index = int(input("Enter the index of the item to de deleted: "))     if (index > len(inventory)):         print("Wrong index,Try Again!")     else:         show(inventory)         inventory.pop(index)         show(inventory) def main():     display_title()     display_menu()     # start with these 3 items     wizard_inventory = [["wooden staff", "Brown", 30.0], ["wizard hat", "Black", 1.5], ["cloth shoes", "Blue", 5.3]]     while True:         command = input("Command: ")         print(command)         if command == "show":             show(wizard_inventory)         elif command == "grab":             grab_item(wizard_inventory)         elif command == "edit":             edit_item(wizard_inventory)         elif command == "drop":             drop_item(wizard_inventory)         elif command == "exit":             break         else:             print("Not a valid command. Please try again.\n")             print("Bye!") if __name__ == "__main__":     main()

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I don't need the get_new_item and the color of the items but it breaks the code, how do I fix this?

WEIGHT_LIMIT = 100
COUNT_LIMIT = 4
wizard_inventory = []


def display_title():
    print("The Wizard Inventory program")
    print()


def display_menu():
    print("COMMAND MENU")
    print("show - Show all items")
    print("grab - Grab an item")
    print("edit - Edit an item")
    print("drop - Drop an item")
    print("exit - Exit program")
    print()


def show(inventory):
    print("Show inventory")
    for i in inventory:
        print(i[0], i[1], "(", i[2], ")lbs")
    total = calculate_weight(inventory)
    print("Total Weights is : ", total, "lbs")
    print(" Weight limits of 100 lbs")


def calculate_weight(inventory):
    total = 0
    for i in inventory:
        print(i[2])
        total = total + float(i[2])
    return total
def grab_item(inventory):
    list = []
    total = 0
    if (len(inventory) < 4):
        list.extend(get_new_item())
        print(list)
        total = calculate_weight(inventory)

        total = total + float(list[2])
        print(total)
    if (total < 100):
        inventory.append(list)
    else:
        print("weight exceeds limit of 100 lbs")
        show(inventory)
# create a function which adds new items
def get_new_item():
    New_Items = []
    # store item in list
    for i in range(3):
        New_Items.append(input(f'Enter value at index {i}: '))
    return New_Items
def edit_item(inventory):
    index = int(input("Enter the index of the item to de edited: "))
    if (index > len(inventory)):
        print("Wrong index,Try Again!")
    else:
        Newname = input("Enter the new name for the item: ")
        print("Before edit : ", inventory[index])
        inventory[index][0] = Newname
        print("After edit : ", inventory[index])


def drop_item(inventory):
    index = int(input("Enter the index of the item to de deleted: "))
    if (index > len(inventory)):
        print("Wrong index,Try Again!")
    else:
        show(inventory)
        inventory.pop(index)
        show(inventory)


def main():
    display_title()
    display_menu()

    # start with these 3 items
    wizard_inventory = [["wooden staff", "Brown", 30.0], ["wizard hat", "Black", 1.5], ["cloth shoes", "Blue", 5.3]]
    while True:
        command = input("Command: ")
        print(command)
        if command == "show":
            show(wizard_inventory)
        elif command == "grab":
            grab_item(wizard_inventory)
        elif command == "edit":
            edit_item(wizard_inventory)
        elif command == "drop":
            drop_item(wizard_inventory)
        elif command == "exit":
            break
        else:
            print("Not a valid command. Please try again.\n")
            print("Bye!")

if __name__ == "__main__":
    main()

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY