Sum and min won't work correctly on assignment

I have an assignment to analyze data in csv file for countries and what year they had lowest and highest life expectancy from the Spanish Flu. I keep getting the error “line 21, in
expectancy = int(line[3])
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ‘27.638\n’”
I have no idea why this keeps coming up so any tips would be great!

lowest = 99999999
highest = -1
low_entity = ""
low_year = ""
high_entity = ""
high_year = ""
input_year = ""

input_year = input("Enter the year of interest: ")
print()

with open("life-expectancy.csv") as file:
    next(file)

    for line in file:
        line = line.split(",")

        entity = line[0].strip()
        code = line[1]
        year = int(line[2])
        expectancy = (line[3])

        min_country = min(entity)
        min_life = min(expectancy)
        avg_life = sum(expectancy) / len(expectancy)

        #max_life = -1
        #min_life = min(expectancy)
        #avg_life = sum(expectancy) / len(expectancy)

        max_country = ""
        max_year = max(year)
        min_country = min(entity)
        min_year = min(year)

        if expectancy > highest:
            highest_value = expectancy
            max_entity = entity
            max_year = year
        if expectancy < lowest:
            min_value = expectancy
            min_entity = entity
            min_year = year
            #min_life = min(expectancy)
           # min_country = min(entity)
        if input_year == year:
            print(f"For the year {input_year}.\n")
            max_life = expectancy
            min_life = expectancy
            max_country = entity
            min_country = entity
        

        print()
        print(f"The overall max life expectancy is:{max_life:.2f} from {max_country} in {max_year:.2f}.\n")
        print(f"The overall min life expectancy is:{min_life:.2f} from {min_country} in {min_year:.2f}.\n")
        print(f"The average life expectancy across all countries was str{avg_life:.2f}\n")
        print(f"The max life expectancy was in {max_country} with {max_life:.2f}\n")
        print(f"The min life expectancy was in {min_country} with {min_life:.2f}\n")

First of all - newline should be stripped. However, this will not solve the problem - to convert string to integer using int string must represent an integer literal in the given base

>>> int('27.638')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '27.638'
>>> int('27')
27
>>> help(int)
Help on class int in module builtins:

class int(object)
 |  int([x]) -> integer
 |  int(x, base=10) -> integer
 |
 |  Convert a number or string to an integer, or return 0 if no arguments
 |  are given.  If x is a number, return x.__int__().  For floating point
 |  numbers, this truncates towards zero.
 |
 |  If x is not a number or if base is given, then x must be a string,
 |  bytes, or bytearray instance representing an integer literal in the
 |  given base.  The literal can be preceded by '+' or '-' and be surrounded
 |  by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
 |  Base 0 means to interpret the base from the string as an integer literal.

If you’re going to work with .csv files, I’d recommend that you use the csv module.

There’s also a nice tutorial here:

For what it’s worth, int() has no problem dealing with leading and trailing whitespace. int(' 12 \n') returns 12.

Mea culpa. You are absolutely correct.