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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:55:56+00:00 2026-05-26T11:55:56+00:00

I am looking for a specific string in a list; this string is part

  • 0

I am looking for a specific string in a list; this string is part of a longer string.

Basically i loop trough a text file and add each string in a different element of a list. Now my objective is to scan the whole list to find out if any of the elements string contain a specific string.

example of the source file:

asfasdasdasd
asdasdasdasdasd mystring asdasdasdasd
asdasdasdasdasdasdadasdasdasdas

Now imagine that each of the 3 string is in an element of the list; and you want to know if the list has the string “my string” in any of it’s elements (i don’t need to know where is it, or how many occurrence of the string are in the list). I tried to get it with this, but it seems to not find any occurrence

work_list=["asfasdasdasd", "asdasdasdasd my string asdasdasdasd", "asdadadasdasdasdas"]
has_string=False

for item in work_list:
    if "mystring" in work_list:
        has_string=True
        print "***Has string TRUE*****"

print " \n".join(work_list)

The output will be just the list, and the bool has_string stays False

Am I missing something or am using the in statement in the wrong way?

  • 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-26T11:55:57+00:00Added an answer on May 26, 2026 at 11:55 am

    You want it to be:

    if "mystring" in item:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a general question, but here is the specific case I'm looking for
I've got this Excel Workbook which I want to search for a specific string
I am looking for specific guidelines for when to use Web Services frameworks versus
I'm am looking for specific suggestions or references to an algorithm and/or data structures
Let's say that I'm looking for a specific item in a has_many association. Is
I'm looking for a very specific eclipse plugin that will tell me if a
I'm not looking so much for language-specific answers, just general models for implementing a
I am looking for an answer to a specific problem of fetching whole LINQ
I'm looking for a way to determine if a specific tray on a given
I'm looking to find records in a table that match a specific number that

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.