Hi there,
I am taking a quiz and one of the questions asked what the output of the code included below would be:
dictionary = {
'one': 'two',
'three': 'one',
'two': 'three'
}
v = dictionary['one']
for k in range(len(dictionary)):
v = dictionary[v]
print(v)
I know that the answer is: two
But, I am unsure how we came up with that result.
I know that this line: v = dictionary[‘one’]
equals two but the for loop that follows it confuses me and im assuming that the answer to this question is two because the for loop didn’t change the original value of the first instance of v
Can someone explain to me what exactly is going on in this code?
I really appreciate any help,
Thank you!