I've brought in these global variables from my main module into my other modules, but they won't update. I know this because I tried to print the value of the variables after they were supposed to have been updated.
All variables start at '0'
This is the 'module_doors'
def one(pills, batteries, lighter):
while True:
doorone = input("A, B or C?:\n").lower()
if doorone.lower() not in ('a', 'b', 'c'):
print("That item doesn't exist, try again.")
print('')
else:
break
if doorone.lower() == 'a':
batteries = 1
print('These could come in handy later.')
if doorone.lower() == 'b':
lighter = 1
print("Maybe it's a light source. Doesn't look brand new though, not sure how long it'll last.")
if doorone.lower() == 'c':
pills = 1
print('Could save your life, good choice.')
I've then tried to print them in another module to check, like this:
import module_doors
def lobby(pills, batteries, lighter):
if lobbydeci.lower() == 'b':
print("")
time.sleep(0.3)
print('Only one key remaining, Nice!')
print('')
print("It says '0001' on the tag.")
module_spacing.spacing()
module_doors.one(pills, batteries, lighter)
module_doors.two(pills, batteries, lighter)
print(batteries)
print(lighter)
print(pills)
This is printing just 0's for all the variable values, even though they were supposed to update.
Thanks