Python Forum
Appending list Trouble Big Time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Appending list Trouble Big Time
#1
I am trying to append a list of elements to a larger list as I iterate through the data. Something crazy is happening.

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]
Reply


Messages In This Thread
Appending list Trouble Big Time - by Milfredo - Sep-28-2020, 05:37 AM
RE: Appending list Trouble Big Time - by bowlofred - Sep-28-2020, 05:53 AM
RE: Appending list Trouble Big Time - by Milfredo - Sep-28-2020, 06:30 AM
RE: Appending list Trouble Big Time - by deanhystad - Sep-28-2020, 08:25 PM
RE: Appending list Trouble Big Time - by Milfredo - Sep-28-2020, 11:02 PM
RE: Appending list Trouble Big Time - by deanhystad - Sep-29-2020, 02:44 AM
RE: Appending list Trouble Big Time - by Milfredo - Sep-29-2020, 07:35 AM
RE: Appending list Trouble Big Time - by Milfredo - Oct-01-2020, 02:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  trouble reading string/module from excel as a list popular_dog 0 429 Oct-04-2023, 01:07 PM
Last Post: popular_dog
  Time.sleep: stop appending item to the list if time is early quest 0 1,883 Apr-13-2021, 11:44 AM
Last Post: quest
  Reading and appending list MrSwiss 1 1,733 Mar-01-2021, 09:01 AM
Last Post: Serafim
  concatenating 2 items at a time in a python list K11 3 2,355 Oct-21-2020, 09:34 AM
Last Post: buran
  list trouble rediska 3 2,241 Oct-17-2020, 11:17 AM
Last Post: ibreeden
  Appending to list of list in For loop nico_mnbl 2 2,373 Sep-25-2020, 04:09 PM
Last Post: nico_mnbl
  trouble with list array Milfredo 2 2,048 Sep-16-2020, 12:07 AM
Last Post: Milfredo
  Trouble with converting list , dict to int values! faryad13 7 3,779 Sep-04-2020, 06:25 AM
Last Post: faryad13
  appending list of list glennford49 2 2,150 Mar-29-2020, 09:33 AM
Last Post: ibreeden
  Trouble with list function Eggman72 2 1,745 Mar-23-2020, 09:36 PM
Last Post: Eggman72

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020