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

Igor Lukin
Igor Lukin
1,689 Points

Why Task 1 is no longer passing although i'm not modifying old variables from task 1?

Can't get why as i'm writing 3d task code it says that task 1 is no longer passing, although i'm not touching variables from task 1?

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(dicts):
  max_value = 0
  teach = ''
  new_list = []
  for key in dicts:
    new_list = dicts[key]
    if len(new_list) > max_value:
      max_value = len(new_list)
      teach = key
  return teach

def num_teachers(dicts):
  num = 0
  for key in dicts:
    num += 1
  return num

def stats(new_dicts):
  grand_list = []
  new_lis2 = []
  for key in new_dicts:
    new_list2 = [key,len(new_dicts[key])
    grand_list.append(new_list2)
  return grand_list

2 Answers

Ryan Ruscett
Ryan Ruscett
23,309 Points

Hey,

Some of the exercises go like this.

Task 1

  1. Do abc.
  2. A test, checks to see if it's right.

Task 2

  1. Do def
  2. Checks if TASK 1 and 2 are correct.

Task 3

  1. Do ghi
  2. Checks if TASK 1, 2 and 3 are correct.

Ok, so now that is out of the way. Let's think about this. If 1 and 2 passed before but are not now. We didn't change any of those variables, what else could cause those tasks to fails?

  1. I am not directly changing those variables but I could be altering a reference? <----not likely

ANSWER

  1. I made a mistake in task 3, which is causing the program to not compile. If the program can not compile, Task 1 and 2 would fail. Since the test for Task 3 must compile, pass 1 and 2 before it get's to three to print to you some other error message. If it doesn't compile it fails on the first test. Which is 1.

So it's likely that you have some sort of syntax error that is keeping the program from compiling. Thus task 1 can not do it's check to see if it's correct and just fails.

One trick is to go back to task 1. Then put your full code in there. If I do that, I see you have a syntax error in your task 3 code.

def stats(new_dicts):
  grand_list = []
  new_lis2 = []
  for key in new_dicts:
    new_list2 = [key,len(new_dicts[key])
    grand_list.append(new_list2)
  return grand_list

Fix the code and you should be all set.

let me know if that answers your question or if I can help in any other way.

Thanks

Igor Lukin
Igor Lukin
1,689 Points

Thank you so much! It really helped - as it turned out, i had some syntax error with parenthesis (not enough). But this message about task 1 is so confusing, though. I bet, i'm not the first one and not the last one to catch this kind of message. How do we report about this kind of problems in code challenges program?