Question: 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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f539225d2a0_97766f53921f11c0.jpg)
![names: nameFirst, nameLast = name.split() sol[nameFirst] = list() sol[nameFirst].append(nameLast) firstName.append(nameFirst) return sol](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f53922e6098_97866f5392297a61.jpg)

!["(" + ", ".join("Sr: "join("%r: ".join("%r: % (key, (key, (key, diclkey]) dic](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f5392417023_97966f53923a97f9.jpg)
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
Get step-by-step solutions from verified subject matter experts
