Problem in guided project: prison break

min_year = min(data, key=lambda x: x[0])[0]
max_year = max(data, key=lambda x: x[0])[0]
years = []
for y in range(min_year, max_year + 1):
    years.append(y)
    
attempts_per_year = []
for year in years:
    attempts_per_year.append([year, 0])

print(attempts_per_year)
TypeError                                 Traceback (most recent call last)
<ipython-input-41-7fa204666547> in <module>
----> 1 min_year = min(data, key=lambda x: x[0])[0]
      2 max_year = max(data, key=lambda x: x[0])[0]
      3 years = []
      4 for y in range(min_year, max_year + 1):
      5     years.append(y)

TypeError: '<' not supported between instances of 'int' and 'str'

Why do i get this error? Help me :frowning:

This error might be as a result of having instances of integers and strings. Do a double check on your data to see where there may be strings.

i suggest you put each line of code in a separate cell and run each individually before proceeding to the next line of code in another cell.
in this particular case, i suggest you first run the code for min and max year and print it and check if you’re getting the correct value.