Sep-28-2020, 05:37 AM
I am trying to append a list of elements to a larger list as I iterate through the data. Something crazy is happening.
$ python pyfuncs.py
EYE ON THE FINISH
GODSGIFT
LILLET
I DON'T WANT TO GO
RELEASE THE HEAT
FOGGY FLIGHT
This is what I get when printing the appended list.
[0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16, 0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16, 0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16, 0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16, 0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16, 0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16]
def extract_horse_data(): horses_name.append( xx[horse_count][18]) horses_info.append( xx[horse_count][0]),horses_info.append( xx[horse_count][1]), horses_info.append(xx[horse_count][2]), horses_info.append( xx[horse_count][3]),horses_info.append( xx[horse_count][4]), horses_info.append(xx[horse_count][5]), horses_info.append( xx[horse_count][6]),horses_info.append( xx[horse_count][7]), horses_info.append(xx[horse_count][8]), horses_info.append( xx[horse_count][9]),horses_info.append( xx[horse_count][10]), horses_info.append(xx[horse_count][11]), horses_info.append( xx[horse_count][12]),horses_info.append( xx[horse_count][13]), horses_info.append(xx[horse_count][14]), horses_info.append( xx[horse_count][15]),horses_info.append( xx[horse_count][16]), horses_info.append(xx[horse_count][17]), horses_info.append( xx[horse_count][18]) print(horses_info[18]) #READ FILE AND PULL OUT HORSES AND HORSE INFO FOR SELECTED RACE AND TRACK for horse_count in range(0,len(xx)): if int(xx[horse_count][1])== int(race_number): horses_info.clear() extract_horse_data() #load_horse_data() hcount+=1 print(horse_single_race_info)As you can see the names print out just fine. But when I print out the horse_single_race_info all I get is just the last horse and none of the first 5 horses. I don't understand what I'm doing wrong.
$ python pyfuncs.py
EYE ON THE FINISH
GODSGIFT
LILLET
I DON'T WANT TO GO
RELEASE THE HEAT
FOGGY FLIGHT
This is what I get when printing the appended list.
[0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16, 0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16, 0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16, 0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16, 0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16, 0.0, 15.62, 14.29, 7.58, 14.04, 8.8, 1.6, 'FOGGY FLIGHT', 16]