This way looks good... but isn't
dict2 = dict1
for key, value in dict2.items():
dict2[key] = value[0]
print(dict2) # good so far
print(dict1) # oh no!
When we say dict2 = dict1
all we're doing is pointing the variable name dic2 to the dictionary stored at dict1. Both names will point to the same place. Superficially,
dict2 = dict1.copy()
for key, value in dict2.items():
dict2[key] = value[0]
print(dict2) # good so far
print(dict1) # okay....
Seems to work, though you will want to look up shallow vs. deep copy if you're using more complicated structure than tuples (specifically, mutable values)
In one line, this is equivalent to
dict2 = { key : val[0] for key, val in dict1.items() }
This has the added benefit of avoiding the referencing problem from your original implementation. Again, if you have mutable types (e.g., list of lists instead of tuple of integers, there is still some chance that your values are pointing to the same place, leading to unexpected behaviour)
There are some subtle differences between dictionaries in python2 and python3. The dictionary comprehension above should work for both