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

  • Home
  • SEARCH
  • 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 8747691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:23:54+00:00 2026-06-13T12:23:54+00:00

I am new to Python. I am writing a string function to check if

  • 0

I am new to Python. I am writing a string function to check if a certain string contains certain multiple values. Is there a syntax in python to allow me to do something like this:

def strParse(str):
    a = 't'
    b = 'br'
    c = 'ht'
    if a in str AND b in str AND c in str:
        print('Ok!')

(The part I am unsure about is having multiple if statements on line.) Thanks!

  • 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-13T12:23:55+00:00Added an answer on June 13, 2026 at 12:23 pm

    Almost correct, just make the and lower-case:

    def strParse(str):
        a = 't'
        b = 'br'
        c = 'ht'
        if a in str and b in str and c in str:
            print('Ok!')
    

    Doesn’t cause problems in this case, but you should avoid using variable-names that are also built-in functions (str is a builtin function/type)

    If you have more values, you can do the same thing more tidily like so:

    values = ['t', 'br', 'ht']
    if all(x in instr for x in values):
        print("Ok!")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Python, writing something with pygame and it is very bitmap
I am a bit new to Python, but an experienced programmer. I am writing
I'm really new to C -> Python interaction and am currently writing a small
Question: Is there a way to make a function object in python using strings?
I'm new to Python and come from a Java background. I'd like to know
I'm new to python and I'm writing a code to upload a file using
I am quite new to python programming (C/C++ background). I'm writing code where I
I'm new to python. I'm writing a script that calls a command line tool
I am new to Python, and I'm working on writing some database code using
I'm a new Python programmer who is making the leap from 2.6.4 to 3.1.1.

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.