I cannot get the return total part to work, this is in python by the way.

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 cannot get the return total part to work, this is in python by the way.

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 + i[2]
return total

def grab_item(inventory):
    list = []
    total = 0
if(len(inventory)<4):
    list.extend(get_new_item())
    total = calculate_weight(inventory)
  
    total = total + list[2]
    print(total)
if(total < 100):
    inventory.append(list)
else:
    print("weight exceeds limit of 100 lbs")
    show(inventory)

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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 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