Skip to content
← Back to Community
food simulation
Profile icon
AbdullaAl5

Why this error accured
try to input 1 then input 1-11
LINE 187

Voters
Profile icon
AbdullaAl5
Comments
hotnewtop
Profile icon
RYANTADIPARTHI

i think the error is because bu_y is not an integer indice. You should only put integers as [].

Profile icon
AbdullaAl5

@RYANTADIPARTHI it still error

Profile icon
jameswill22

If you live in the USA and are a panda express restaurants customer, then you should try this panda express survey at https://pandaexpresscomfeedbackss.com/ and win a meal for free. We all know that panda express restaurant is very famous for its fast-food items.

Profile icon
Dunce

buy = food[int(bu_y)]

Profile icon
AbdullaAl5

@Dunce it still error

Profile icon
Dunce

@AbdullaAl5 Can I see the error message you're getting?

Profile icon
AbdullaAl5

@Dunce
image

Profile icon
Dunce

@AbdullaAl5 if I'm deciphering your code correctly, you're trying to grab the index of where every the string that matches bu_y is, but bu_y is a string, so it can't be used as an index, however there are other ways of doing this, here is an example:

for i in range(len(food)): if food[i] == bu_y: buy = i
Profile icon
BananaJellyfish

i think you have to convert it to an integer using int(bu_y)

Profile icon
AbdullaAl5

@BananaJellyfish it still error