Use setdefault and tuple unpacking
Remove whitespace in empty line and useless newlines
Remove useless check
Separate data from code