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 trialBlake Handson
1,642 PointsMy console isn't working in Python! Help!
Ok, so I have a python program I am trying to run via the console for a challenge. The workspace console is being stubborn, or I am being silly and missing something. I am receiving the following error when trying to run the test_code.py file which resides in the 'Teacher App' folder in workspaces -
python test_code.py
File "<stdin>", line 1
python test_code.py
^
SyntaxError: invalid syntax
This is driving me crazy! Any ideas ?
Thanks :)
# The dictionary will be something like:
dicts = {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],
'Kenneth Love': ['Python Basics', 'Python Collections']}
def most_classes(dicts): #function name -- passes in a dictionary
most_class = "" # holds the name of teach with most class
max_count = 0 # max counter for classes
for teacher in dicts:
if len(dicts[teacher]) > max_count:
max_count = len(dicts[teacher])
most_class = teacher
return most_class
def num_teachers(dicts):
busy_teacher = 0
for key in docts.keys():
busy_teacher += 1
return busy_teacher
[MOD: added ```python markdown formatting - cf]
1 Answer
Chris Freeman
Treehouse Moderator 68,428 PointsWhen working in Workspaces,
- make sure the file has been saved. (not dot next to filename in it's tab above the editor.
- make sure the console is displayed. From the Workspace menu, choose View --> Show Console
- in the console, at the prompt, type "
python test_code.py
":
treehouse:~/workspace$ python test_code.py
Your current file defines a dict and two functions, so no output will be created unless you add code to call the functions, such as:
print(most_classes(dicts))
print(num_teachers(dicts))
Justin Horner
Treehouse Guest TeacherJustin Horner
Treehouse Guest TeacherHello Blake,
Would you post the contents of the test_code.py file for us?
Thanks :)