I am trying to create any number of instances in a class depending on the user's input but so far I unable to:
class CLASS_INVENTORY:
maxcount_inventory = int(input("How many Inventories: "))
for count_inventory in range(maxcount_inventory):
def __init__(Function_Inventory, inventory_name(count_inventory)):
add_inventory = str(input("Enter Inventory #%d: " % (count_inventory+1)))
inventory_name[count_inventory] = add_inventory
Note: I'm kind of new in Python 3 so I'm not sure if some of my syntax are right.
I want the output to be like this:
How many Inventories: 4
Enter Inventory #1: Fruits
Enter Inventory #2: Veggies
Enter Inventory #3: Drinks
Enter Inventory #4: Desserts
Here's my full code: https://pastebin.com/3FBHgP6i I'd also like to know the rules in writing Python 3 code if I'm following them right or I should change something. I'd like it to be readable as much as possible for other Python programmers.
class ClassName(object):, where object is the type that ClassName sub-classes or implments (which may actually be object, in most cases). In general, it is also recommended to follow the PEP8 guidance. This is easiest followed if you use a text-editor or IDE that supports PEP8 (e.g., Atom with some community plugins and pip packages).