modify Python variable value

Asked

Viewed 40 times

0

I need the value that is written in the variable "add_money" to be added and added in the variable "balance"

saldo = 0
op = input('O que deseja fazer? ') 
if op == 'add': add_money = int(input('Qual sera o valor? ')) 
add_money + saldo 
print(saldo)

1 answer

1


You need to specify which variable you want to add the balance to add_money

Tends this way

saldo = 0
op = input('O que deseja fazer? ') 
if op == 'add': 
    add_money = int(input('Qual sera o valor? ')) 
    saldo = add_money + saldo 
    print(saldo)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.