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 6780711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:32:17+00:00 2026-05-26T16:32:17+00:00

Working in Python 2.7. I have two different lists, A and B (simplified to

  • 0

Working in Python 2.7.

I have two different lists, A and B (simplified to make explanations more clear).

A = [1, 2, 4, 3, 5]
B = [2, 0, 3, 2, 1]

I would like to be able to compare the positional values of each list ex- A[1] v B[1]- and total up the instances in which A is larger (A “wins”), the instances when the two values are the same (A “ties”), and the instances when B is larger (A “losses”).

To make things a little more complicated I’m also using random.shuffle() to randomize the order of the list every time through a for loop.

I first tried using:

def listComp(listA, listB):
    Awins = 0
    Aties = 0
    Alosses = 0
    for i in range(0, whatever):
        random.shuffle(listA)
        random.shuffle(listB)
        if A[0] > B[0]:
            Awins += 1
        elif A[0] == B[0]:
            Aties += 1
        elif A[0] < B[0}:
            Alosses += 1

And then in each of the if statements, coding additional if statements to account for all the possible variations. Obviously, this gets very labor-intensive as the size of the list grows. There’s got to be an easier way, right?

  • 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-26T16:32:18+00:00Added an answer on May 26, 2026 at 4:32 pm

    Sounds like you want zip:

    def compare(A,B):
        Awins = 0
        Aties = 0
        Alosses = 0
        for i in range(0, whatever):
            random.shuffle(listA)
            random.shuffle(listB)
            for a,b in zip(A,B):
                if a > b:
                    Awins += 1
                elif a == b:
                    Aties += 1
                else:
                    Alosses += 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working in python 2.7. I have two lists (simplified to make explanations clearer). T
I would like to exchange objects between two python interpreters working on the same
i'm using python twisted and i have two separate servers working, one that recieves
I am working in Python with an Email() class that I would like to
I have recently been working with Python using Komodo Edit and other simpler editors
I need to have an at-home project now that I'm working on Python/Django at
I'm working on my first object oriented bit of python and I have the
I am working with Google App Engine and Python. I have a model with
I'm wondering if anyone have a good resource for working with Corba in Python?
How can you have model declarations at two different directories in Django? I have

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.