I'm doubtful in a college exercise, I need to store 3 data which are: Vehicle number, kilometers rotated and consumption in each variable of type list, but due to being different types, with the first 2 being integers and the last float, besides having the entry on the same line, I can not store them.
I thought about trying to store it this way:
idcar=[] #Numero de cada veiculo
kms=[] #Quilometros rodados
consumo=[] #Consumo de cada veiculo
for i in range(10):
idcar[i],kms[i],consumo[i]=map(float,raw_input().split())
And then transform the float values (the idcar and kms), to integer but to my misfortune this error appears:
Traceback (most recent call last):
File "consumo1.py", line 17, in <module>
idcar[i],kms[i],consume[i]=map(float,raw_input().split())
IndexError: list assignment index out of range
Given that the entries are given in this way, with 10 different values:
1001 231 59.2
1002 496 60.4
...
Adding important information that I forgot to put: In the end I must calculate the average consumption (Km / L) for each identified car and finally in the output I should print for each car its average consumption, in addition to saying which are the 2 worst consumptions between the cars.
I would love it if you could help me, thank you in advance, I hope that I have written clearly my doubts, this is the first time I write here.