Tokenize a string: Difference between revisions
Content added Content deleted
(Add Seed7 example) |
|||
Line 153: | Line 153: | ||
'''Interpreter:''' Python 2.5 |
'''Interpreter:''' Python 2.5 |
||
words = "Hello,How,Are,You,Today" |
words = "Hello,How,Are,You,Today" |
||
list_of_words = words.split(',') |
|||
print '.'.join(list_of_words) |
|||
If you want to print each word on its own line: |
|||
This prints each word on its own line. If we want to follow the task specification strictly, we join the array elements with a dot, then print the resulting string: |
|||
for word in list_of_words: |
|||
print '.'.join("Hello,How,Are,You,Today".split(',')) |
|||
print word |
|||
or |
|||
Or replace the '.' with '\n' and do: |
|||
print "\n".join( |
print "\n".join(list_of_words) |
||
==[[Ruby]]== |
==[[Ruby]]== |