Python Forum
Python inventory system with dicts.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python inventory system with dicts.
#5
Ok, i got that part figured out, thanks, but im confused.. again. Apple already has 10, but when I go to add it, if I want to add 2, so it is 12, it sets it equal to 2. I also can't figure out the remove part at all.

intro = input("What would you like to do?: ")
 
if intro == "add" or intro == "Add":
    where = input("Where would you like to add?: ")
    item = input("What would you like to add?: ")
    amount = int(input("How much would you like to add?: "))
     
    inv[where][item] += amount
    print(item + ": " + str(amount))
 
elif intro == "remove" or intro == "Remove":
    where = input("Where would you like to remove?: ")
    item = input("What would you like to remove?: ")
    amount = int(input("How much would you like to remove?: "))
    
    inv[where][item] = item - int(amount)
    print(item + ": " + str(amount))
Reply


Messages In This Thread
RE: Python inventory system with dicts. - by 2skywalkers - Aug-21-2018, 03:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove duplicates from dicts with list values wardancer84 27 6,814 May-27-2024, 04:54 PM
Last Post: wardancer84
  Advice for Inventory System Extra 0 2,014 Feb-18-2022, 09:25 PM
Last Post: Extra
Star Recursively convert nested dicts to dict subclass Alfalfa 1 4,002 Jan-22-2021, 05:43 AM
Last Post: buran
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 20,211 Jan-11-2021, 06:30 PM
Last Post: ykumar34
  Split dict of lists into smaller dicts of lists. pcs3rd 3 3,459 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  Communicating Roblox's Inventory API with python? 4TH4RV 1 3,050 Jun-22-2020, 10:30 AM
Last Post: snippsat
Question Difference between Python's os.system and Perl's system command Agile741 13 9,832 Dec-02-2019, 04:41 PM
Last Post: Agile741
  Still working with dicts menator01 2 2,705 Nov-07-2019, 07:15 AM
Last Post: perfringo
  convert List of Dicts into a 2 deep Nested Dict rethink 1 4,222 Aug-23-2019, 05:28 PM
Last Post: ichabod801
  Merge dicts without override chisox721 4 4,428 Jul-20-2019, 01:45 AM
Last Post: chisox721

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020