I have a list of days and want to create a dictionary that maps first 3 letters of the day to the full name.
I tried:
day=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
daydict = dict()
for d in day:
daydict.update({d[:3]:d})
which gives the desirable result but, then I stumbled upon code which seems more clean.
daydict = dict((d[:3],d)for d in day)
I don't understand this syntax. Please explain how dict((d[:3],d)for d in day)
works?