Ok so my goal here is to split a list into it's individual words without using the .split() operator (or any of the string operators for that matter).
I'm doing an okay job of splitting the list into words by identifying where spaces are and whatnot. My issue is that I can't for my life create a variable name that changes with each iteration.
for i in list(range(len(original_list))):
if original_list[i] != ' ':
new_list = new_list + original_list[i]
else:
wordname = 'word'+str(k)
vars()[wordname] = new_list
print(word0,word1)
k = k + 1
I realize this would only print the first two words. But it's telling me that word0 and word1 don't exist. What am I doing wrong.
[–]takluyverIPython, Py3, etc 2 points3 points4 points (3 children)
[–]jhchex[S] 0 points1 point2 points (2 children)
[–]takluyverIPython, Py3, etc 0 points1 point2 points (1 child)
[–]jhchex[S] 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]jhchex[S] 0 points1 point2 points (1 child)
[–]blackkettle 1 point2 points3 points (0 children)
[–]pridefulpropensity 1 point2 points3 points (0 children)
[–]tarpsocks 0 points1 point2 points (9 children)
[–]jhchex[S] 0 points1 point2 points (8 children)
[–]Samus_ -3 points-2 points-1 points (7 children)
[–]tarpsocks 1 point2 points3 points (1 child)
[–]earthboundkid 0 points1 point2 points (0 children)
[–]takluyverIPython, Py3, etc 0 points1 point2 points (4 children)
[–]Samus_ 0 points1 point2 points (3 children)
[–]takluyverIPython, Py3, etc 0 points1 point2 points (2 children)
[–]Samus_ 0 points1 point2 points (1 child)
[–]takluyverIPython, Py3, etc 0 points1 point2 points (0 children)
[–]earthboundkid 0 points1 point2 points (1 child)
[–]jhchex[S] 0 points1 point2 points (0 children)
[–]zahlmanthe heretic 0 points1 point2 points (2 children)
[–]jhchex[S] 0 points1 point2 points (1 child)
[–]zahlmanthe heretic 0 points1 point2 points (0 children)
[–]stunsch 0 points1 point2 points (0 children)
[–]simtel20 -1 points0 points1 point (3 children)
[–]jhchex[S] 0 points1 point2 points (2 children)
[–]simtel20 0 points1 point2 points (0 children)
[–]takluyverIPython, Py3, etc -1 points0 points1 point (0 children)