#๐Ÿ”’ game inventory help

19 messages ยท Page 1 of 1 (latest)

rigid aurora
silent nebulaBOT
#

@rigid aurora

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

neon folio
#

people won't know what information you're looking for from that. do you have a question?

rigid aurora
rain night
#

that is your inventory. an orange, a wooden staff, and a wooden torso armor.

neon folio
#

if you want it to display in some particular way, do you have code anywhere that would create that display? otherwise there's no reason it'd show how you want

rain night
#

you implemented __str__, but list uses __repr__ to display the items.

neon folio
#

they fall back on each other don't they? or is it only str that falls back on repr

rain night
#

oh, indeed. the default __str__ is __repr__.

neon folio
#

!e

class SimplePotion:
    id_type = "healthpot"
    id_rarity = "basic"
    id_heal = 20

    def __str__(self):
        return "Health Potion I"

print(repr(SimplePotion()))
silent nebulaBOT
neon folio
#

is it though? I don't remember this stuff any more

#

in any case -- you might not want to display the list itself but rather print out the individual items.
to do something for each thing in a list you'd use a loop

rain night
#

Currently the function is: py def invent_display(display_items): print(f"""\nInventory: {display_items}""")

#

You could write each item separately using a loop: py def invent_display(display_items): print() print("Inventory:") for item in display_items: print(f"\N{BULLET} {item}")

silent nebulaBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.