0

So basically I want a program that will only work if the user types something like "I am sick" or "I am too cool" but will not work if they make a typo like "pi am cool".

Here's what I have so far:

text = input("text here: ") 
if re.search("i am", text) is not None:
   print("correct")
1
  • 2
    And what's the question? Commented Sep 6, 2013 at 3:01

1 Answer 1

5

While you still haven't asked an actual question, it seems to me like you want something along the lines of

if text.lower().startswith('i am'):
    print('correct')

Or if you want to test if 'i am' appears anywhere in the string and not just at the start, you can use in:

if 'i am' in text.lower():
    print('correct')

Regular expressions seem like overkill here (unless you want more flexibility than what you describe).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.