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 trial

Python Python Collections (Retired) Dictionaries Teacher Stats

Welby Obeng
Welby Obeng
20,340 Points

Bummer! `courses()` seems to be missing some courses

I dont know why i will get the message "Bummer! courses() seems to be missing some courses"..I tested the code below in workspaces and it works just fine

dicts = {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],'Welby Obeng': ['Ruby Foundations','Ruby Foundations','Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],
'Kenneth Love': ['Python Basics', 'Python Collections']}

def courses(dicts):
  classes = []
  for courses in dicts.values():
    for course in courses:
      classes.append([course])
  print(classes)

courses(dicts)

treehouse:~/workspace$ python stats.py
[['Python Basics'], ['Python Collections'], ['Ruby Foundations'], ['Ruby on Rails Forms'], ['Technology Foundations'], ['Ruby Foundations'], ['Ruby Foundations'], ['Ruby Foundations'], ['Ruby o n Rails Forms'], ['Technology Foundations']]

What is the context of the challenge? What exactly is it asking you to do?

Welby Obeng
Welby Obeng
20,340 Points

Write a function named courses that takes the dictionary of teachers. It should return a list of all of the courses offered by all of the teachers.

1 Answer

Welby Obeng
Welby Obeng
20,340 Points

I figured it out...read the instructions wrong...i was making each course a list; as a result it gave a list full of lists...I removed [] around course and it was good

Good to hear! Always nice when you are able to work through issue.