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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:13:45+00:00 2026-06-11T05:13:45+00:00

Consider the below piece of code: searchList=[hello, hello world, world] pattern = ‘hell’ matchingList

  • 0

Consider the below piece of code:

searchList=["hello", "hello world", "world"]
pattern = 'hell'
matchingList = [t for t in searchList if re.match(pattern, t)]

The above code works fine in Jython 2.4.3 but fails in lower versions of Jython with this error:

ValueError: iterator indices must be consecutive ints starting at 0

Any workarounds?

With this below work around, am gettign the same error:

  for t in searchList:
      if re.match(pattern, t):
          matchingList.append(t)

Error seen in Jython 2.1

  • 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-11T05:13:47+00:00Added an answer on June 11, 2026 at 5:13 am

    The code works fine on cpython 2.3.5, 2.2.3, 2.1.3, and 2.0 as well as jython 2.2.1, 2.2, and 2.1. List comprehensions are only available in 2.0+. Instead, you can write:

    # Warning: This code is unnecessarily complex because of cpython 1.x (!) support
    import re
    searchList=["hello", "hello world", "world"]
    pattern = 'hell'
    matchingList = []
    for t in searchList:
        if re.match(pattern, t):
            matchingList.append(t)
    

    That being said, even 2.4 is ancient and has been unsupported for quite a while (this means that you must manually apply and adapt all security patches since then to have a secure system). The Python versions you’re catering to are more than a decade old, and almost certainly riddled with security vulnerabilities. Consider deprecating Python 2.5 and older.

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

Sidebar

Related Questions

Consider the below code to save data in array, arr[]['name'] = 'hello'; arr[]['value'] =
Consider the code below, private void Convert_Click(Object sender, RoutedEventArgs e) { string[] strCmdLineParams =
Consider the code below. I don't understand why my GCC compiler does not try
My questions are divided into three parts Question 1 Consider the below code, #include
Consider below code: template<typename T> void f(T a[]) { if(sizeof(T) > 1) for(...)a[i] =
Consider below functions f(int a[]) { ///CODE for for if(a[i] > 0) //change i
I want to determine which attribute to look-up dynamicaly, Consider below python code: def
Consider the below code fragment: double * p = new double[16]; int value =
Please Consider my below xml code and screen shot(To view the large screen shotplease
consider below code class Repository{ public static Item i; //Item is a type (class)

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.