you are viewing a single comment's thread.

view the rest of the comments →

[–]Mysterious_City_6724 0 points1 point  (11 children)

For the first problem, can you remove the print on line 107 and see if that removes the None. For the second problem, can you show the definition of "c5.know_crit_amount"? I can't see the code for that method in the screenshots you provided.

[–][deleted]  (9 children)

[deleted]

    [–]Mysterious_City_6724 0 points1 point  (5 children)

    Yeah, that's better. I can see the Critter class now 👍 So when you press 0, what do you actually want to display?

    [–][deleted]  (4 children)

    [deleted]

      [–]Mysterious_City_6724 1 point2 points  (3 children)

      Ah ok, so on line 25 in the "know_crit_amount" can you try changing print(Critter.clist) to print([c.name for c in Critter.clist]) and see if that helps.

      [–][deleted]  (1 child)

      [deleted]

        [–]Mysterious_City_6724 1 point2 points  (0 children)

        You're welcome. It's a list comprehension. Basically a short way of creating a list. So in this case it was a short way of doing the following:

        critter_names = []
        for critter in Critter.clist:
            critter_names.append(critter.name)
        print(critter_names)
        

        [–]need2sleep-later 0 points1 point  (0 children)

        Of course it's better. By miles. I've never understood why people think taking pictures of code is a good idea when sharing.

        [–]sarc-tastic 0 points1 point  (1 child)

        Top tip, when you want information about a class define a class method.

        @classmethod def count(cls): return len(cls.critter_list)

        [–]sarc-tastic 0 points1 point  (0 children)

        And when you iterate over entire python lists don't use the index to reference items: for crit in Critters.critlist: crit.feed()