Need to find the average of scores of the user when user inputs the gamer id
The csv file:
name tribe id Score1 Score2 Score3 Score4
Aang Normad N321B 89 67 54 78Gyatso Omaticay O111C 54 78 65 54
i tried adding in some stuff I found on SO, but got the error: invalid literal for int() with base 10: 'Score1'. Will appreciate anyone that can point me in the right direction, just began learning python.
import csv
filePath="data.csv"
with open(filePath) as csvfile:
avatar_id= input ("Enter Avatar ID:")
reader = csv.DictReader(csvfile)
for row in reader:
if avatar_id in row['id']:
#just print some stuff
user,tribe,id, *scores= row
average= sum([int(score) for score in scores])/4
print("{0:>6}{1:>8}{2:>7}{3:>7}{4:^14}".format(row['Air'],row['Water'],row['Earth'],row['Fire'], average))
print("==============================")
else:
x=5
if x>4:
print('No avatar found')