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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:52:42+00:00 2026-06-09T21:52:42+00:00

I wrote a script in python to tell which numbers in new were in

  • 0

I wrote a script in python to tell which numbers in new were in the first 10 numbers in new. I know it looks more complicated than it has too and that has to do with what I’m trying to do with the script later. For now though I’m trying to figure out why it’s printing ‘each’ for EVERY number in the list ‘new’ and not just the ones before the tenth.

Here’s my code:

i = 10
new = ['A lot of numbers'] 

for each in re.findall(r'[0-9]+', new):
    if any(each for x in (re.findall(r'[0-9]+', new)[0:i])):
        print each
    else:
        pass
  • 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-09T21:52:44+00:00Added an answer on June 9, 2026 at 9:52 pm

    You need to refer to x somehow in your generator expression, or else you’re just checking any([each, each, each, ....]), which will always evaluate to true if each evaluates to true (which it always will for your regular expression). I suspect you want something like this, which tests if any of the first i items is equal to each:

    if any(x==each for x in (re.findall(r'[0-9]+', new)[0:i])):

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

Sidebar

Related Questions

I wrote the following script, which generates a SyntaxError : #!/usr/bin/python print Enter the
So I wrote a Python script which does some simple stuff. It was originally
I know how what to write in a python script to tell a unix
I wrote a simple script using python-daemon which prints to sys.stdout : #!/usr/bin/env python
I wrote a little Python script wrapcl.py script which wraps our compiler binary (
I wrote a python script which just stopped working suddenly. I'm not sure why
I wrote a Python script which initializes an empty database if it doesn't exist.
I wrote a python script which I am using to download a large number
I've wrote a python script to check whether a condition has been fulfilled(in this
I wrote a python script which downloads data via the Yahoo! Finance API and

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.