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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:53:47+00:00 2026-06-12T09:53:47+00:00

How do I fix this error, pos_coordinates contains a list of values and the

  • 0

How do I fix this error, pos_coordinates contains a list of values and the updatePos_coordinates is the previously pos_coordiantes values copied into the updatePos_coordinates list. I want to find the differences between the object and index value 8, 9, 12, and 13. but I kept on getting this error. How do I solve this

    screen_width = 0
    screen_height = 0
    updatePos_coordinates = []

    while True:
        client_socket.send("loc\n")
        data = client_socket.recv(8192)
        pos_coordinates = data.split()

        if(not(pos_coordinates[-1] == "eom" and pos_coordinates[0] == "start")):
            continue

        if (screen_width != int(pos_coordinates[2])):
            screen_width = int(pos_coordinates[2])
            screen_height = int(pos_coordinates[3])

        if (pos_coordinates != updatePos_coordinates):
            if(cmp(pos_coordinates[8:10], updatePos_coordinates[8:10]) == 0):
                both.brake()
                print "Ball is in the same location.."
            if((pos_coordinates[8] - updatePos_coordinates[8] > 5) or (pos_coordinates[8] - updatePos_coordinates[8] < -5) or (pos_coordinates[9] - updatePos_coordinates[9] > 5) or (pos_coordinates[9] - updatePos_coordinates[9] < -5)):     
                activateRobot(pos_coordinates)
            else:
                both.brake()
                print "Ball is in the same location.."

        updatePos_coordinates = pos_coordinates[:]
        time.sleep(3)
        print '...........'

and I keep on getting this:

Traceback (most recent call last):
  File "test.py", line 155, in <module>
    if((pos_coordinates[8] - updatePos_coordinates[8] > 5) or (pos_coordinates[8] - updatePos_coordinates[8] < -5) or (pos_coordinates[9] - updatePos_coordinates[9] > 5) or (pos_coordinates[9] - updatePos_coordinates[9] < -5)):     
IndexError: list index out of range
  • 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-06-12T09:53:48+00:00Added an answer on June 12, 2026 at 9:53 am

    You are trying to access updatePos_coordinates[8] when it doesn’t have any elements yet, as it hasn’t been changed since you defined it as updatePos_coordinates = [].

    You should fill updatePos_coordinates with default values before the loop.

    For example:

    updatePos_coordinates = ['' for _ in range(16)]
    # replace 16 with length of pos_coordinates
    

    Alternatively, you could just make both coordinates equal to each other the first time through the loop.

    if len(updatePos_coordinates) < 16:
        updatePos_coordinates = pos_coordinates[:]
    
    elif pos_coordinates != updatePos_coordinates:
        ...
    

    I’ve also noticed that you are treating the coordinates like integers, when they are actually strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I fix this error? I can't find anything to help me! Code
How to fix this error in SharePoint: The list cannot be displayed in Datasheet
How to fix this error? @echo off Setlocal EnableDelayedExpansion REM LINES FOR TEST: REM
How do I fix this error? error C2668: 'std::_Tree<_Traits>::end' : ambiguous call to overloaded
How can I fix this error, and install thin or other gems? $ sudo
How to fix this error that happens on Debian Linux using ssl commands with
Dose anyone know how to fix this error? I installed zorba and it worked
I've been trying to fix this error: {exception:Persistent class \Class org.myapp.model.Account does not seem
I'm getting this error in the log.... What can I do to fix this?
What causes this error, how can I fix it? Detailed Error Information Module IIS

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.