0

I'm new to Python wondered if someone could explain how I can use this games object to save to when user inputs all the different variables and then print the results.

Class games:
   def __init__(self, name, platform, genre, no_of_players, online_functionality):
        self.name = name
        self.platform = platform
        self.genre = genre
        self.players = no_of_players
        self.functionality = online_functionality
        games.games_list.append(self)
  • 1
    Use a list or dictionary to store instances of this class. Also, name it `Game` rather than `games` – kindall May 02 '20 at 15:20
  • Can you explain little more what is the problem here? – AKA May 02 '20 at 15:21
  • In another function I will be getting user input for the variables name, platform etc. How do I use my games object to save the data and then also print from it. I especially don't know how I can print from this object? – user12410388 May 02 '20 at 15:26
  • Create new game instances with new_game = Games() and pass the data as arguments inside the parens like listed in the __init__ def line. – progmatico May 02 '20 at 15:27
  • I have stored instances of this class in a list and am getting this [<__main__.games object at 0x042193B8>] when trying to print the instances of the class entered by the user? can anyone explain how I can successfully code printing the records? – user12410388 May 02 '20 at 15:41
  • Does this answer your question? [How to print instances of a class using print()?](https://stackoverflow.com/questions/1535327/how-to-print-instances-of-a-class-using-print) – stovfl May 02 '20 at 16:14

0 Answers0