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 Regular Expressions in Python Introduction to Regular Expressions The Basics

Use open() to load the file "basics.txt" into the variable file_object.

I cant see the indentation error. Can someone point it out?

Thanks,

basics.py
def file_object():
    with open('basics.txt') as file:

    if __name__ **''__main__':
    file_object(input(" "))

2 Answers

Ari Misha
Ari Misha
19,323 Points

Hiya there! Well, you don't have to squeeze the code in the function when it is not asked in the challenge, 'coz it'll throw an error for sure. Moreover, the code wasn't correct as well. The challenge wants you to open a file with open() function and store the contents of the file in a variable. And here is how your code should look like:

with open('basics.txt') as file:
    file_object = file

I hope it helped!

~ Ari ~

Thank Ari Misha, I remembered this code being in the teacher's note on the first video.

Thanks