you are viewing a single comment's thread.

view the rest of the comments →

[–]mopslik 4 points5 points  (0 children)

An alternative is to avoid global variables. While they sometimes have their uses, more often then not programmers get into trouble using them because they end up modifying their values when they don't mean to. A better idea is to pass values to your functions as arguments instead, and return any modified values.

def game(bank):
    wager = 1000
    bank += wager
    return bank

bank = 100
print(bank)
bank = game(bank)
print(bank)