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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:03:44+00:00 2026-05-26T14:03:44+00:00

Working in python 2.7. I have two lists (simplified to make explanation more clear):

  • 0

Working in python 2.7.

I have two lists (simplified to make explanation more clear):

T = [[1, 0], [1, 0], [0, 5], [3, -1]]
B = [[1], [3], [2], [2]]

And three functions.

def exit_score(list):
    exit_scores = []
    length = len(list)
    for i in range(0, length):
        score = list[i][2] - list[i][0]
        exit_scores.append(score)
    return exit_scores

First I append the corresponding values of B to the corresponding lists in T:

def Trans(T, B):
    for t, b in zip(T, B):
        t.extend(b)
    a = exit_score(T)
    b = T
    score_add(b, a)

Then, using the previously listed exit_score function. I subtract the the value in the list[2] position from the value in the list[0] position fore each list. I then append those results to another list (exit_scores).

Finally, I want to add the exit_scores (now a), to the original list.

So I use my score_add(b, a) function which is:

score_add(team, exit_scores):
    for t, e in zip(team, exit_scores)
        t.extend(e)
    print team

If everything were working correctly, I would get an output like this:

[[1,0,1,0], [1,0,3,-2], [0,5,2,-2], [3,-1,2,1]]

Instead, I get a TypeError telling me that I can’t iterate over an integer. But I’ve tried printing both a and b and both are in list form!

When I change the code to make sure that the exit scores are in a list:

def Trans(T, B):
    es = []
    for t, b in zip(T, B):
        t.extend(b)
    es.append(exit_score(T))
    score_add(T, es)

The entire exit_scores list (es) is added to the end of the first list of T:

[[1, 0, 1, 0, 2, 2, -1], [1, 0, 3], [0, 5, 2], [3, -1, 2]]

For the life of me, I can’t figure out what I’m doing wrong…

  • 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-26T14:03:45+00:00Added an answer on May 26, 2026 at 2:03 pm

    This time it’s list.append(), not list.extend():

    def score_add(team, exit_scores):
        for t, e in zip(team, exit_scores)
            t.append(e)
        print team
    

    B was a list of lists, while exit_scores is a list of integers.

    Edit: Here is a cleaned-up version of the whole code:

    for t, b in zip(T, B):
        t.extend(b)
        t.append(t[2] - t[0])
    
    • 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
Working in Python 2.7. I have two different lists, A and B (simplified to
I have two strings in python that I have converted to lists: Seq1 =
i'm using python twisted and i have two separate servers working, one that recieves
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?
I'm very new to python. two days. trying to get a plot working with

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.