I'm a little bit new to python but i know like the basics like variables and strings, i recently create a discord bot with a currency and a shop. The shop doesn't work, its meant to let me buy a ticket for the item listed (it isn't meant to store anything).Could you please help me find out where i went wrong and help me make it better or show me where i went wrong where i can find me my answer. Here is what i got for the shop (note i'm using python 3.6.4):
@client.command(pass_context = True)
async def buy(ctx, item):
items = {
"Apex Legends":[3,20],
"Minecraft":[5,30],
"Halo":[5,20],
"Fortnite":[8,10],
}
while True:
print("Apex Legends = 3BP / Minecraft = 5BP / Halo = 5BP / Fortnite = 8BP")
print("Account Balance bp",stash)
choice = input("What would you like to buy?: ").strip().title()
if choice in items:
if items[choice][1]>0:
if stash>=items[choice][0]:
items[choice][1]=items[choice][1]-1
stash= stash-items[choice][0]
print("Thank you..!")
print("")
else:
print("Sorry you don\'t enough money...")
print("")
else:
print("sorry sold out")
print("")
else:
print("Sorry we don\'t have that item...")
print("")
If you want to see my full code on the bot its on here: https://hastebin.com/tojadefajo.py
while True:
as this will enter an infinite loop since you have no break
statements!print()
statements with await client.say()
statementsTry this
@client.command(pass_context = True)
async def buy(ctx, item):
items = {
"Apex Legends": [3, 20],
"Minecraft": [5, 30],
"Halo": [5, 20],
"Fortnite": [8, 10],
}
await client.say("Apex Legends = 3BP / Minecraft = 5BP / Halo = 5BP / Fortnite = 8BP")
await client.say("Account Balance bp", stash)
choice = input("What would you like to buy?: ").strip().title()
if choice in items:
if items[choice][1]>0:
if stash>=items[choice][0]:
items[choice][1]=items[choice][1]-1
stash= stash-items[choice][0]
await client.say("Thank you..!")
await client.say("")
else:
await client.say("Sorry you dont enough money...")
await client.say("")
else:
await client.say("sorry sold out")
await client.say("")
else:
await client.say("Sorry we don't have that item...")
await client.say("")
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments