Python Forum
Python simple store inventory system.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python simple store inventory system.
#3
The way to do it is with a dictionary: inventory = {'food': [], 'tools': [], ...}. By using strings for the keys, this allows you to use the user's input as a key: inventory[cato].append(item).

You may want to look at the collections module, specifically defaultdict. It provides an easy way to do this.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Python simple store inventory system. - by ichabod801 - Aug-19-2018, 05:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Advice for Inventory System Extra 0 1,344 Feb-18-2022, 09:25 PM
Last Post: Extra
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 16,736 Jan-11-2021, 06:30 PM
Last Post: ykumar34
  How does a set in python store the elements? idknuttin 5 2,828 Jul-10-2020, 10:46 PM
Last Post: Gribouillis
  Communicating Roblox's Inventory API with python? 4TH4RV 1 2,117 Jun-22-2020, 10:30 AM
Last Post: snippsat
Question Difference between Python's os.system and Perl's system command Agile741 13 6,953 Dec-02-2019, 04:41 PM
Last Post: Agile741
  Reading blob data from database by python and store it in .zip format Adityasi 2 6,692 Nov-18-2019, 05:22 PM
Last Post: ibreeden
  How do I install apps from google play store? using python + selenium.. mongo 0 2,302 Aug-05-2019, 12:41 AM
Last Post: mongo
  Store a product/item in a inventory program viktoria_linn 1 4,112 Jul-02-2019, 09:26 PM
Last Post: DeaD_EyE
  Store a python list of lists in a database to use for searches later on klllmmm 3 3,109 Jun-20-2019, 07:54 AM
Last Post: buran
  What area unit the opposite ways in which to understand if an inventory in Python is Smhbugra 2 2,521 May-27-2019, 07:55 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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