how to have python check for certain word/phrase for raw input

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PythonNotSoGuru
    New Member
    • Oct 2007
    • 21

    how to have python check for certain word/phrase for raw input

    Hi everyone i was just wondering if there is anyway to have python check for a specific word or phrase in a raw input value. If you could please provide a small example code chunk to help me along that would be great. I have no idea how this would be attempted so any suggestions would be terrific.
    code (Python)
    platform windows
    os windows XP pro
    python version 2.5

    thanx again
  • ilikepython
    Recognized Expert Contributor
    • Feb 2007
    • 844

    #2
    Originally posted by PythonNotSoGuru
    Hi everyone i was just wondering if there is anyway to have python check for a specific word or phrase in a raw input value. If you could please provide a small example code chunk to help me along that would be great. I have no idea how this would be attempted so any suggestions would be terrific.
    code (Python)
    platform windows
    os windows XP pro
    python version 2.5

    thanx again
    [code=python]
    word = "word"

    if word in raw_input("Ente r a sentence: "):
    print "found word"
    else:
    print "word not found"
    [/code]

    Comment

    Working...