Solution in python3 using dictionary


#1

we can use a default dictionary