Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class Improvement
#5
Thank you for your positive feed back. I'm glad to here that. I will do my best
(Apr-19-2020, 08:13 PM)michael1789 Wrote: You'll have to take a bit of time to learn dictionaries. They are super useful and worth your time. https://www.youtube.com/watch?v=daefaLgNkw0&t=384s is great video.

This is not a complete working example. But after you watch that video or read up on dictionaries a little I can help you further. Any way you want to do it is just as good, but this is an idea to cycle through a dictionary of dictionaries and produce a final dictionary that holds all the info for that particular animal. It's just a rough suggestion. As I said, familiarize yourself with dictionaries and I'll be happy to work you through it as best I can.

Class Animal:
      def __init__(self):
            self.dictionaries = {1 : nutrition, #<-- dicts like my previous post
                                 2 : respiratory, 
                                 3 : excretory, 
                                 4 : reproductive, 
                                 5 : climate}
            self.data = {}
            self.input_function()

            
      def input_function(self):
          for i in range(1, 5):
              answer = input(self.dictionaries[i][input_text]
              self.data.update(i : self.data[i][answer])
Reply


Messages In This Thread
Class Improvement - by Gokberk - Apr-18-2020, 09:58 AM
RE: Class Improvement - by michael1789 - Apr-18-2020, 05:34 PM
RE: Class Improvement - by Gokberk - Apr-19-2020, 09:25 AM
RE: Class Improvement - by michael1789 - Apr-19-2020, 08:13 PM
RE: Class Improvement - by Gokberk - Apr-19-2020, 10:16 PM

Forum Jump:

User Panel Messages

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