def process_cars(text_file):
total_cmpg = 0
for line in text_file:
if((line % 2) == 0):
city_mpg = (line[52:54])
print(city_mpg)
city_mpg = int(city_mpg)
total_cmpg += city_mpg
print ("Total miles per gallon in the city:", total_cmpg)
The error comes in the if((line % 2) == 0): I have searched on the other questions with the same error but none of them could solve the problem. The error is: Not all arguments converted during string formatting. I want to mod the position of the line. For example if it is the third line then, 2 % 2.
line % 2are you trying to mod the number from line?