I am trying to convert a string such as 'SUP E P I C' to a tuple containing all the non-spaced strings. For example, if the input is 'SUP E P I C', then the program should return ('S', 'U', 'P', 'E', 'P', 'I', 'C') and I am trying the obvious method of looping, and I started as follows:
for ch in john:
if ch != ' ':
j1 += ch
else:
# stuff
I'm stuck because I can add the first entry of the tuple but after that skipping the space is just escaping me. Any hints would be much appreciated!
j1 += chwon't work ifj1is atupleandchis a string. gnibbler's solution is clearer and simpler, and maybe even faster, but your solution is fine, except for this one problem.