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 Escapes

Suryapratap Singh Rathore
Suryapratap Singh Rathore
3,012 Points

file is not there

i could not find file which i need to read

escapes.py
import re
name_file = open("names.txt", encoding = "utf-8")
data = name_file.read()
first_number = re.search(r'\d',data)

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Hi Suryapratap Singh Rathore! The challenge says "Write a function named first_number that takes a string as an argument.". So you solution will be of the form:

import re

def first_number(string):
    # your code here
    return your_results

In general, challenges that ask for a named function to be defined are expecting to call that function with various arguments to test to behavior of the function. In this case, it will pass in various strings to see if the results match expectations.

Post back if you need more help! Good luck!!