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 Trying Out Python

Solomon Petruzzi
Solomon Petruzzi
219 Points

In the workspace when I click ENTER, it does not come out right

The following shows up when I click ENTER. Traceback (most recent call last):
File "/home/treehouse/workspace/app.py", line 3, in <module>
print['My name is']
TypeError: 'builtin_function_or_method' object is not subscriptable

4 Answers

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Data Analysis Techdegree Graduate 45,972 Points

Yes this is happening because of the square brackets. I changed your code to this...

name = 'Solomon'

print('My name is')
print(name)

Make sure you save your file, you'll see the dot next to the file name in the tab up top disappear when it's saved, then in the console type

python app.py

and hit enter. I was presented with the following output

treehouse:~/workspace$ python app.py                                                                                                                                    
My name is                                                                                                                                                              
Solomon                
Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Data Analysis Techdegree Graduate 45,972 Points

It's a bit hard to tell without seeing your code, but from what you've posted it's likely because the print() method requires parentheses ( ) and not square brackets [ ]. I would try changing it to

print('My name is')

If this doesn't help, please create a snapshot of your Workspace seen at the 4:40 mark of that video and post your link here and we'll take a closer look :thumbsup:

Solomon Petruzzi
Solomon Petruzzi
219 Points

Also the print() does not work either