Answered step by step
Verified Expert Solution
Question
1 Approved Answer
def countNames(names): sol = {} firstName = [] for name in names: nameFirst, nameLast = name.split() sol[nameFirst] = list() sol[nameFirst].append(nameLast) firstName.append(nameFirst) return sol Test print
def countNames(names): sol = {} firstName = [] for name in names: nameFirst, nameLast = name.split() sol[nameFirst] = list() sol[nameFirst].append(nameLast) firstName.append(nameFirst) return sol
Test print (countNames ((1)) dic=countNames( ["Michael Jackson", "Michael Jordan", "Michael Douglas "1) "(" + ", ".join("Sr: "join("%r: ".join("%r: % (key, (key, (key, diclkey]) dic [key]) diclkey]) print %r" for key in sorted (dic)) + ")" x dic countNames ([" Meghan Markle", "Prince Harry", "Meghan Trainor", "Prince William"]) print "(" + ", %r" % for key in sorted(dic)) ")" + x dic-countNames (["Mike Flynn","Adam Wager"Adam Dj", "Marie Lee", ""]) print "(" + ", %r" % for key in sorted (dic)) "}" +Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started