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.

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

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
Chris Freeman
Treehouse Moderator 68,227 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!!