How To Split A Sentence Into Words And Display Each Word Separately

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fellya
    New Member
    • Nov 2008
    • 11

    How To Split A Sentence Into Words And Display Each Word Separately

    Hi,

    i don't have enough experience in writing codes in Python but now i'm trying to see how i can start using Python.
    I've tried to write a simple program that can display a sentence. now my problem is how to write a code using split function to split that sentence into words then print out each word separately. let me give u an example:

    >>>sentence=" My question is to know how to write a code in Python"

    then the output of this sentece must give:

    sentence[1]=My
    sentence[2]=question
    sentence[3]=is
    sentence[4]=to
    sentence[5]=know
    ......
    .......

    Can someone help me in this?
  • oler1s
    Recognized Expert Contributor
    • Aug 2007
    • 671

    #2
    Duplicate question. Don't double post.

    Comment

    Working...