#๐Ÿ”’ ๐Ÿ”’ please help explain this inventory management code

16 messages ยท Page 1 of 1 (latest)

autumn heartBOT
#

Hey @neat turret!

Please edit your message to use a code block

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
#

@neat turret

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.

raven arch
#

thats a lot to explain. Do you have a problem with which line specifically?

#

you mean itemInventory.index or itemNumber[index]?

#

Right so do you know what the list itemNumber looks like?

#

ok but what does a filled list of itemNumber looks like?

#

that's strange. it should have picked up the index of the first juice and increase its itemNumber on that index

#

So it increases by += 1 on the index of the same item in itemInventory

#
        index = itemInventory.index(item)
        itemNumber[index] +=1

When trying to find the index of the item that you're looking for example item = juice, then the index should be 0

#
        index = itemInventory.index('juice')
        print(index) # shows 0
        itemNumber[index] +=1
#

Then to increase the count of that juice in itemNumber list, you increase it by 1 in itemNumber[index] +=1

#

It doesn't append or increase the list size. It just adds the current int count of that same index by 1

Longer form looks like

        index = itemInventory.index('juice')
        print(index) # shows 0
        itemNumber[0] = itemNumber[0] + 1 # replacing "index" with the value 0
autumn heartBOT
#
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.

#

๐Ÿ”’ please help explain this inventory management code

autumn heartBOT
#
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.