Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Guided Prison Break: Fetch_year function #160

Open
MyNameisMatt1 opened this issue Jun 7, 2022 · 1 comment
Open

Problem with Guided Prison Break: Fetch_year function #160

MyNameisMatt1 opened this issue Jun 7, 2022 · 1 comment

Comments

@MyNameisMatt1
Copy link

MyNameisMatt1 commented Jun 7, 2022

Hello, I'm at mission 610 and I have a problem when I try replace the full date with just the year:

This is the code I'm using.

for row in data:
    date = fetch_year(row[0])
    row[0] = date

This is the error I get...

TypeError                                 Traceback (most recent call last)
<ipython-input-10-8a078f6cee5c> in <module>
      1 for row in data:
----> 2     date = fetch_year(row[0])
      3     row[0] = date

~/notebook/helper.py in fetch_year(date_string)
     10 
     11 def fetch_year(date_string):
---> 12     return int(re.findall("\d{4}", date_string)[0])
     13 
     14 def barplot(list_of_2_element_list):

/dataquest/system/env/python3/lib/python3.8/re.py in findall(pattern, string, flags)
    237 
    238     Empty matches are included in the result."""
--> 239     return _compile(pattern, flags).findall(string)
    240 
    241 def finditer(pattern, string, flags=0):

TypeError: expected string or bytes-like object

@Abhishek-jha07
Copy link

Bro write this code instead
for row in data:
row[0] = fetch_year(row[0])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants