【发布时间】:2017-08-14 13:36:49
【问题描述】:
我今天刚开始使用 python,我已经看到了与其他编程语言的一些差异。
我无法让它工作。
我有一个余额需要在调用存款函数时提高,但它保留的值是它给出的最后一个值。
balance = 0
counter = 0
def deposit(amount):
global balance
balance = balance + amount
counter += 1
print (balance + counter)
deposit (1000)
deposit (10100)
【问题讨论】:
-
确保在发布 Python 代码时准确地复制缩进。否则,您将在代码中引入新错误。
-
define "I can't get this to work." 它是否无法编译、是否崩溃、是否给您带来意想不到的结果?
标签: python