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

How do i get through this task

Functions and Dictionaries

teachers.py
# The dictionary will be something like:
# {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],
#  'Kenneth Love': ['Python Basics', 'Python Collections']}
#
# Often, it's a good idea to hold onto a max_count variable.
# Update it when you find a teacher with more classes than
# the current count. Better hold onto the teacher name somewhere
# too!
#
# Your code goes below here.
def most_classes(my_dict):
  teachers_list = {}
  for teacher in my_dict:
    teachers_list[teacher] = len(my_dict[teacher])
  return max (teachers_list, key = teachers_list.get)

def num_teachers(my_dict):
  teachers_list2 = []

I am getting the gist of it but second task is not passing. its taking me back to task one with the "task one is no longer passing" inscription

Ryan Ruscett
Ryan Ruscett
23,309 Points

Don't go back to task 1. What it's saying when it says task 1 is no longer passing isn't because you did task 1 wrong. It's because your code isn't compiling.

When code compiles it checks for syntax. If the syntax is incorrect the code can not compile. The task run in sequence.

Task 1 - Pass Task 2 - Task 1 failing

This is because on Task 2, the test for task 1 also run.

Task 1 runs task 2 runs

Except if the code can't compile. Than test 1 would fail. Since it failed and didn't compile Thus all the test would fail. Goes like this

Task 1 Compiles code Runes the test.

Task 2 Compiles code Runs test 1 Runes test 2

If the code fails at compiling because of a syntax error. Well, compile comes first and if the code can't compile. It means that task 1 is failing. Since it was't able to check it. So when you are on task 2 and it says task 1 has failed. It's because the code didn't compile.

I think treehouse really really really needs to add a tab that actually posts the response. If you take the java track it has compiling errors. You can click the tab and it shows you your compiler errors. Python doesn't have that and it makes it way more difficult than it needs to be.

let me know if this helps.

1 Answer

Ryan Ruscett
Ryan Ruscett
23,309 Points

Hola

I answered this in the post below.

Check it Out

If you are still confused let me know and I can explain it again.