Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRahul Kashyap
1,599 Pointspython dictionaries last challenge! got stuck there don't know why!
showing that didn't get the list expected
# The dictionary will look something like:
# {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'],
# 'Kenneth Love': ['Python Basics', 'Python Collections']}
#
# Each key will be a Teacher and the value will be a list of courses.
#
# Your code goes below here.
def num_teachers(arg1):
count = 0
for key in arg1:
count += 1
return count
def num_courses(arg1):
count = 0
for value in arg1.values():
for items in value:
count += 1
return count
def courses(arg1):
newList = []
for value in arg1.values():
for items in value:
newList.append(items)
return newList
def most_courses(arg1):
valueCheckDict = {}
for key in arg1.keys():
maxCount = 0
for items in arg1.values():
maxCount += 1
valueCheckDict[key] = maxCount
s = ""
maxi = 0
for key1 in valueCheckDict.keys():
if valueCheckDict[key1] > maxi:
s = key1
maxi = valueCheckDict[key1]
return s
def stats(teachersDict):
listOver = []
count = 0
for key in teachersDict.keys():
listInside = []
listInside.append(key)
for value in teachersDict[key]:
count += 1
listInside.append(count)
listOver.append(listInside)
return listOver
#def most_courses(teacher_dict):
# max_count = 0
# rockstar = ""
# for teacher, course_list in teacher_dict.items():
# if len(course_list) > max_count:
# 3 max_count = len(course_list)
# rockstar = teacher
# return rockstar
Rahul Kashyap
1,599 PointsRahul Kashyap
1,599 Pointswhat I did wrong in my last function stats()!! Not passing!!reply ASAP!