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 trialKaren Shumate
13,579 PointsUse open() to load the file "basics.txt" into the variable file_object.
I cant see the indentation error. Can someone point it out?
Thanks,
def file_object():
with open('basics.txt') as file:
if __name__ **''__main__':
file_object(input(" "))
2 Answers
Ari Misha
19,323 PointsHiya 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 ~
Luis Barahona
4,529 PointsThank Ari Misha, I remembered this code being in the teacher's note on the first video.
Karen Shumate
13,579 PointsThanks
merc1er
6,329 Pointsmerc1er
6,329 PointsLine 3