Python: How should we interpret this for loop?
arr = ['b','c','d'] # a list called arr x={1:'a'} # a dictionary called x n = 1 for x[n] in arr: # what is going on here? n+=1 # What if there is no such thing as x[2], x[3], x[4] etc... ? print(x) # outputs {1: 'b', 2: 'c', 3: 'd'} From my understanding, x[n] refers to the dictionary's n key, which is string 'a'. What does for x[n] in arr (or for 'a' in arr) mean? Is this analogous to: for i in ['b','c','d'] where i is an an arbitrary letter to denote "item in list"? Referring to line n+=1 I also don't understand what happens if there are no such thing as x[2], x[3], x[4] etc... After all, the dictionary only has one key:value pair...