Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Use open() to load the file "basics.txt" into the variable file_object.
I cant see the indentation error. Can someone point it out?
def file_object(): with open('basics.txt') as file: if __name__ **''__main__': file_object(input(" "))
Ari Misha19,274 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 ~