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 trialApus Wsoe
7,555 PointsError`first` doesn't seem to be a regex match. Works in Preview first = r'Four' print(re.match(first, data))
I'm stuck on challenge task 4/5 with the error first
doesn't seem to be a regex match. It does appear to work in the Preview though. first returns "Four" What's am I doing wrong this time?
import re
file_object = open("basics.txt", encoding="utf-8")
data = file_object.read()
file_object.close()
first = r'Four'
re.match(first, data)
4 Answers
Kenneth Love
Treehouse Guest TeacherYou need to assign the re.match()
to the first
variable.
first = re.match(...)
shezazr
8,275 Pointsyou are doing re.match(first, data) but where is it going to end up at present? i.e. accessable?
Apus Wsoe
7,555 PointsI first tried
print(re.match(first, data))
...but that didn't work either. Is that what you mean? Making it accessible via print?
Apus Wsoe
7,555 PointsThanks! I get it now!