Ask coding questions

← Back to all posts
Updating a database using variables.
druceb (15)

Have tried multiple online solutions for updatign a database using a variable but none have worked. Please help!!

The code for updating is in the update procedure.

McJoe21 (2)

I have had similar problems with nodejs

xolyon (347)

I am not sure but I think you need to have a global variable in your function ...

Stonks = 0
#your intial varible
def Stock_add(amount):
    # telling the program that the varible is global (function must go after varible
   global stonks
    print("adding stocks")
    #adding to stonks by local parameter
    stonks += amount```
druceb (15)

@xolyon I would try this but I don't see how this would help plus you shouldn't really use global variables in programs. Thanks anyway