Last active
December 22, 2015 04:59
-
-
Save AndySum/6421240 to your computer and use it in GitHub Desktop.
This is a fragment of some Python code within a function. I can't understand why it changes the value at key (5,4) and (5,5). When I try this isolated example in a normal compiler it works. how come I get this output?!?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node = (5,4) | |
direction = "South" | |
print "moves is",moves | |
print "i'm going to add",direction,"at",node | |
moves[node].append(direction) | |
print "moves is",moves | |
sys.exit("fuck this") | |
#Output | |
''' | |
moves is {(5, 4): [], (5, 5): []} | |
i'm going to add South at (5, 4) | |
moves is {(5, 4): ['South'], (5, 5): ['South']} | |
fuck this | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I expect to get: moves is {(5, 4): ['South'], (5, 5): []}