回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我开始学习代码,我开始学习python
我想问一些我在jetbrains学院练习的事情</p>
<p>当我编写如下代码时,
我明白了
<strong>TypeError:无法解压缩不可编辑的非类型对象</strong></p>
<p>我知道关于这个打字错误有几个问题,
但我无法理解这些评论,
我也不知道怎么了。。。。
你们中的一些人介意看看这个,告诉我为什么我会出错。。。?
如果有什么尴尬的事情,请多加评论</p>
<pre><code># declaring the current status of the coffee machine
def status(water, milk, beans, cups, money):
print('The Coffee machine has:')
print(water, 'of water')
print(milk, 'of milk')
print(beans, 'of coffee beans')
print(cups, 'of disposable cups')
print(money, 'of money')
# espresso
def espresso(water, beans, money):
water -= 250
beans -= 16
money += 4
return water, beans, money
# latte
def latte(water, milk, beans, money):
water -= 350
milk -= 75
beans -= 20
money += 7
return water, milk, beans, money
# cappuccino
def cappuccino(water, milk, beans, money):
water -= 200
milk -= 100
beans -= 12
money += 6
return water, milk, beans, money
# buy
def buying(water, milk, beans, money):
coffee = input('What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino: ')
if coffee == 1:
water, beans, money = espresso(water,beans, money)
return water, milk, beans, money
elif coffee == 2:
water, milk, beans, money = latte(water, milk, beans, money)
return water, milk, beans, money
elif coffee == 3:
water, milk, beans, money = cappuccino(water, milk, beans, money)
return water, milk, beans, money
status(water, milk, beans, cups, money)
water, milk, beans, money = buying(water, milk, beans, money)
status(water, milk, beans, cups, money)
</code></pre>