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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:54:42+00:00 2026-06-10T13:54:42+00:00

I just started learning Python and need help analyzing data in an excel spreadsheet.

  • 0

I just started learning Python and need help analyzing data in an excel spreadsheet. The excel sheet has i.e. 111122221112211 in one column and I’m trying to figure out how many changes from 1 to 2 or 2 to 1 occur here. In this case, 4 times.

I’ve been told to use set.difference but I don’t understand how. So I tried my own way and get the error ‘list index out of range’ at the elif part. Here is my script (I’m still working on the basics so this may seem very amateur):

a = xlws.Columns(5).value
a = [list(x)[0] for x in a[1:400]]

beam = 0

for x in range(len(a)):
    if a[x] ==1 and a[x+1]==2:
        beam += 1
    elif  a[x]==2 and a[x+1]==1:
        beam += 1
    else: 
        beam = beam 
  • 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-10T13:54:44+00:00Added an answer on June 10, 2026 at 1:54 pm

    The line for x in range(len(a)): should be

    for x in range(len(a)-1):
    

    because you are getting a list element with index x+1 inside the loop and therefore you are reading one element too much.

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

Sidebar

Related Questions

Hi thanks in advance for your help. I'm just getting started learning Python and
I have just started learning python/matplotlib/basemap and could really use some help. How do
I have just started learning python version 3 and trying to create a file
So ive just started learning python on WAMP, ive got the results of a
I just started using/learning Python and have some questions. I have a text file
I've just started learning about Gimp scripting using Python, and was wondering, how do
I just started learning Python... I am writing a simple program that will take
I've just started learning python and I'm using MacVim as my editor with the
I've just started learning Python today. I've been reading a Byte of Python. Right
I'm Java person who just started learning Python. Take this example: class Person(): def

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.