Winning Jeopardy

Screen Link:
https://app.dataquest.io/m/210/guided-project%3A-winning-jeopardy/2/normalizing-text

My Code:
\\import re
def normalize_text(text):
text = text.lower()
text = re.sub("[^A-Za-Z0-9\s]","",text)
return text

def normalize_values(text):
text = re.sub("[^A-Za-z0-9\s]", β€œβ€, text)
try:
text = int(text)
except Exception:
text = 0
return text\\


What I expected to happen:

After I used pd.Series.apply(function)
I was expecting to work
What actually happened:
Instead it throws me an error :bad range character, I looked up over Stackoverflow but still dont know how to cope with this problem.


You are using a-Z instead of a-z

1 Like

Hello.

I’m no regex expert but the pattern you use in the first function is a little different from the one you use in the second one as the second β€œz” in the pattern is uppercase in the first function and lowercase in the second.

@fedepereira Thank you so much, so it’s a sytnax error thanks for noticing and helping out

1 Like

@otavios.s Yes it’s a syntax error which I didn’t notice thanks for pointing out cuz I was really stuck on It.

1 Like