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

I don't understand the error I'm getting in task 5/5 in The Basics code challenge.

import re

file_object = open("basics.txt", encoding="utf-8")
data = file_object.read()
file_object.close()

first = re.match(r'Four', data)
liberty = re.search(r'Liberty', data)

The question is :

"Finally, make a new variable named liberty that is an re.search() for the word "Liberty" in our data variable."

I am getting the 'Oops! It looks like Task 1 is no longer passing.' What is triggering this message, and how can I fix it? Thanks a bunch!

liberty no Liberty l # L

3 Answers

I copied and pasted your code into the question and it ran through all 5 tests and said they were all correct. Maybe there was a temporary glitch?

This is a good question. So if you run this in an editor it will fail encoding is not a proper argument.

If you want encoding in Python you can do an import like this. from io import open

There is an io.open or an open.io which outlines the difference between say Python 2.x and Python 3.x

If I use Python 2.7 to compile your code I will get the same error. If I use python 3.4 I do not. If I import like the example below, I can use your code in python 2.7 and it still works.

Just one of the very few struggles in writing with python is that versions are a cause for porting your code to work for other versions etc.

Hope this helps, let me know if you still have any questions.

Treehouse is using Python 3.4 though, so the original poster should not be getting the error. How are you getting the 'Oops! It looks like Task 1 is no longer passing.' error? That isn't a python interpreter error, it's only an error passed by the interface for the quizzes.

Yes, I think it was a temporary glitch. I reloaded the page several times and all of the code passed.