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

String is not callable

Running a function name that takes a string as an argument. I get a response string is not callable. Don't understand why.

escapes.py
import re

first_number = '25namestest'
print(re.search(r'/d','first_number'))

2 Answers

Defining a variable isn't quite what the challenge is asking for.

Try defining a function instead. Also note that you used a forward slash / instead of a backslash \, and that you surrounded first_number in quotes.

Good luck!

Thanks for the advice: It's late here in the UK and I know I am making a stupid mistake but here is where I am stuck at and I seem to be returning the incorrect answer.

import re

def first_number(): string = '12test' return string

print(re.search(r'\d', 'first_number'))

= 'bummer incorrect answer'

import re

def first_number(string):
    return re.search(r"\d", string)

Here I found the solution thanks for help