Reputation: 391
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")
Upvotes: 0
Views: 73
Reputation: 129477
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).
Upvotes: 5