Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Feb 25th, 2012  |  syntax: Python  |  size: 0.59 KB  |  hits: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. def mysplit(lst):
  3.     words = []
  4.     acc = []
  5.     for ch in lst:
  6.         if ch == ' ':
  7.             if len(acc) > 0:
  8.                 words.append(acc)
  9.                 acc = []
  10.         else:
  11.             acc.append(ch)
  12.     if len(acc) > 0:
  13.         words.append(acc)
  14.     word_count = len(words)
  15.     result = {}
  16.     for i in xrange(word_count):
  17.         word_name = 'word%05d' % (i)
  18.         result[ word_name ] = words[ i ]
  19.     return result
  20.    
  21. result = mysplit('Daniel Lemos Itaborai')
  22. for word_name, word_list in result.iteritems():
  23.     vars()[ word_name ] = word_list
  24. print vars()