1

I have a 2D list containing information about items that the user has added in (like the name of the item, the type, the color etc.). I now want to make a class with all the parameters of the items, I then want to create an object for each item that the user has added in (with all of it's statistics)

What I have in mind is something like this:

clothing_list = [["Black T-Shirt", "Black", "T-Shirt", "Light", "One-Colored"], ["Dark Gray NASA Hoodie", "Dark Gray", "Hoodie", "Warm", "Print"]]

class Clothing:
    def __init__(self, name, color, type, tag, pattern):
        self.name = name
        self.color = color
        self.type = type
        self.tag = tag
        self.pattern = pattern

    @classmethod
    def get_user_input(self):
        while 1:
            try:
                #Getting input from Tkinter
                name = input_name.get()
                color = get_color.get()
                type = get_type.get()
                tag = get_tag.get()
                pattern = get_pattern.get()
            except:
                print("Unable to get user input")
                contunie

After this I somehow want to be able to create an object with their individual stats from the 2D list.

I'm not even sure if this is possible and if it isn't then I'll have to rethink:)

2
  • Does this answers your question? stackoverflow.com/questions/62050496/… Commented Jul 2, 2020 at 11:36
  • @ReblochonMasque heh my bad :) Didn't think that one through fully :D Commented Jul 2, 2020 at 15:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.