Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3314188
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:12:09+00:00 2026-05-17T22:12:09+00:00

I have several lists that I would like to map together, but I can’t

  • 0

I have several lists that I would like to map together, but I can’t quite work my head around how to do it.

I am scraping a live feed of Horse Racing results. The feed only lists the course/time once and three horses and their positions (top three) OR four horses and blank (i.e. “”) positions IF the race was abandoned. These are the lists I have:

course, time, abandoned, horses, position

The lists are in order.

course, time and abandoned all have exactly the same number of elements (abandoned is a list of booleans, True meaning that race was abandoned).

horses is a list of the (3 * number of non abandoned races) + (4 * number of abandoned races) horses.

position is a list of the place positions of the horses. If a race was abandoned the position will be “”, otherwise it is “1”, “2”, “3” (strings!).

Example Lists:

Where no race was abandoned

course = ["Course A", "Course A", "Course B"] #there were two races at course A
times  = ["00:00", "01:00", "15:00"] #Race 1 at Course A was at 00:00, race 2 at course                   A was at 01:00
horses = ["HorseA 1", "HorseA 2", "HorseA 3", "HorseA 4", "HorseA 5", "HorseA 6", "HorseB 1", "HorseB 2", "HorseB 3"] #There are three horses per race

positions = ["1","2","3","1","2","3","1","2","3"]

So, at Course A in the race at 00:00 “HorseA 1” came 1st, “HorseA 2” came 2nd and “HorseA 3” came 3rd.

Where there was an abandoned race

courses = ["CourseX", "CourseX", "CourseY"]
times   = ["01:00",  "02:00", "01:00"]
abandoned = [False, False, True]
horses = ["X1", "X2", "X3", "X4", "X5", "X6", "Y1", "Y2", "Y3", "Y4"]
positions = ["1","2","3","1","2","3","","","",""]

So, there were two races at CourseX but the race at CourseY was abandoned.

What I want to end up with is a list of tuples like so:

[(A Race Course, 00:00, False, Horsey, 1), (A Race Course, 00:00, False, Horsey 2, 2) ... ]

I’m not sure how I can do so, suggestions?

Cheers,

Pete

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:12:09+00:00Added an answer on May 17, 2026 at 10:12 pm
    >>> class s:
        courses = ["CourseX", "CourseX", "CourseY"]
        times   = ["01:00",  "02:00", "01:00"]
        abandoned = [False, False, True]
        horses = ["X1", "X2", "X3", "X4", "X5", "X6", "Y1", "Y2", "Y3", "Y4"]
        positions = ["1","2","3","1","2","3","","","",""]
    
    >>> def races(courses, times, abandoned, horses, positions):
        z = zip(horses, positions)
        for course, time, stopped in zip(courses, times, abandoned):
            for _ in range(4 if stopped else 3):
                horse, pos = next(z)
                yield course, time, stopped, horse, pos
    
    
    >>> print(*races(s.courses, s.times, s.abandoned, s.horses, s.positions), sep='\n')
    ('CourseX', '01:00', False, 'X1', '1')
    ('CourseX', '01:00', False, 'X2', '2')
    ('CourseX', '01:00', False, 'X3', '3')
    ('CourseX', '02:00', False, 'X4', '1')
    ('CourseX', '02:00', False, 'X5', '2')
    ('CourseX', '02:00', False, 'X6', '3')
    ('CourseY', '01:00', True, 'Y1', '')
    ('CourseY', '01:00', True, 'Y2', '')
    ('CourseY', '01:00', True, 'Y3', '')
    ('CourseY', '01:00', True, 'Y4', '')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several unordered lists that I want to display like this: <ul> <li><img></li>
I have several arrays of arrays or arrays of dicts that I would like
I'd like to design something that would allow users to put lists together of,
I have several lists in Matlab that I want to write to the same
I have a directory with several .html files. Would like to read the list
I'm working at a SaaS, where any tenant can have several lists of contacts,
I'm having several lists that are sortable and I can drag elements to each
I have a page with several expandable lists. In a perfect world, I would
I would like to have functionality shared by several models to be abstracted into
I have several lists in a sitecollection that are currently using ListTemplateID 101 (DocumentLibary).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.