Tokenize a string: Difference between revisions
Content added Content deleted
(Nicer variable names) |
|||
Line 226: | Line 226: | ||
'''Interpreter:''' Python 2.5 |
'''Interpreter:''' Python 2.5 |
||
text = "Hello,How,Are,You,Today" |
|||
tokens = text.split(',') |
|||
print '.'.join(tokens) |
|||
If you want to print each word on its own line: |
If you want to print each word on its own line: |
||
for token in tokens: |
|||
print token |
|||
or |
or |
||
print "\n".join(tokens) |
|||
==[[Ruby]]== |
==[[Ruby]]== |