I wish to convert a string into a nested tuple for instance:
string = 'Jane A 3 B- 3 F 1#Bob C+ 2 D+ 3#Chris C 4 C 3 C- 2'
As you can see, the string is not normal with # signs and white-spaces in place of a comma. The # sign is what represents the number of names for which I have to compute some data that follows after each name. So I used string.split('#')
to create 3 separate strings and from there, I used a for loop to get this on the first iteration:
['A', 3, 'B-', 3, 'F', 1]
The reason why 'Jane' is missing from the list is because I only need to take the values, whether it be a string or an integer, and make a nested tuple out of them. Thus, I wish to convert this list into a nested tuple that looks like:
[('A', 3), ('B-', 3), ('F', 1)]
I will greatly appreciate any help or suggestions.