Skip to content

Problem with Guided Prison Break: Fetch_year function #160

@MyNameisMatt1

Description

@MyNameisMatt1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions