Python Data Analysis project code throwing error

Screen Link:[ ]
(Learn data science with Python and R projects)

My Code:
min_year = min(data, key =lambda x: x[0])[0]
max_year = max(data, key = lambda x: x[0])[0]

Replace this line with your code

What I expected to happen: sucessfully run the above code

What actually happened: In the Instructions it was given to copy and paste the same code but unfortunately its throwing an error. I did not write anything in the above code. it is a guided project (prison break).

TypeError                                 Traceback (most recent call last)
<ipython-input-51-40a3764a5e93> in <module>
----> 1 min_year = min(data, lambda x: x[0])[0]
      2 max_year = max(data, lambda x: x[0])[0]

TypeError: '<' not supported between instances of 'function' and 'list'

There doesn’t seem to be anything wrong with the code you shared, so it is highly likely the issue lies somewhere else. Probably you missed or made a mistake on some other instruction that is causing issues now.

It might be better if you shared the rest of the code here. These posts

might help explain how to do that.

Thanks for your quick reply. Actually I got the answers from the solutions. I should have convert variable datatype to date . After doing that above code worked.

1 Like