我是python的新手,我正在这里尝试进行一些数学方面的工作,以保持平衡和平衡。但是该函数定义,不做任何平衡和数量调整。当我打印它们时,它们仍然是库存。
Ballance = 7000 # 7K DEMO
# SANDELYS
Indica_WEED_QUANITY = 600
AMAZON_QUANITY = 18
STEAM_GIFT50_QUANITY = 4
# Price
STEAM_GIFT50_PRICE_PER1 = 50 # Each
Indica_WEED_PRICE_PER1 = 8
Amazon_Prime_PRICE_PER1 = 25 # Each
def PickForShopItem():
ShopPick = int(input("~ PRODUCT ID = "))
if ShopPick == 1:
clear()
while True:
Pasirinxm = input("Would You like to continue buying ~ Indica WEED KUSH * ?\n* Y/N: ")
if "Y" in Pasirinxm or "y" in Pasirinxm:
clear()
BuyKiekis = int(input("~ How many you would to buy of " + Indica_WEED_NAME + "?\n "))
Indica_WEED_QUANITY - BuyKiekis # Atimam Ir paliekam sandari mazesni
Bendra_Suma = ( BuyKiekis * Indica_WEED_PRICE_PER1)
print(Bendra_Suma)
Ballance = 500
print(Ballance - Bendra_Suma)
print("Sandelio Kiekis po pirkimo " + str(Indica_WEED_QUANITY))
print(Ballance)
break
elif "N" in Pasirinxm or "n" in Pasirinxm:
print("xuine iseina")
break
elif " " in Pasirinxm or len(Pasirinxm) < 1:
print("PLease dont do shit")
continue
break
elif ShopPick == 2:
print("Darai")
elif ShopPick == 3:
print("hgelo")
Indica_WEED_NAME = "~ Indica WEED KUSH *
答案 0 :(得分:-1)
我认为您的问题是:
Indica_WEED_QUANITY - BuyKiekis
不更新变量“ Indica_WEED_QUANITY”(并且您在print(ballance - BendraSuma)
行中遇到相同的问题)
在Python中,该语句只会计算出一个值,但是您并没有告诉程序将其保存或存储在任何地方。这样做:
Indica_WEED_QUANITY = Indica_WEED_QUANITY - BuyKiekis
Python还允许您使用-=运算符执行此操作:
Indica_WEED_QUANITY -= BuyKiekis
将通过减去BuyKeikis金额来更新Indica_WEED_QUANITY。