I need to transform a string 'apple/SP++/SW+orange/NNG++/FG+melon/SL+food/JKG' into a list of tuples [('apple', 'SP'), ('+', 'SW'), ('orange', 'NNG'), ('+', 'FG), ('melon', 'SL'), ('food', 'JKG')] I think, first I need to split a string with separator '+', and then split with a separator '/'.
But the problem is that there are two plus signs. First plus sign I need to take as a separator and second one I need to save. If split a string simply with a separator '+', it removes all plus signs:
s = 'apple/SP++/SW+orange/NNG++/FG+melon/SL+food/JKG'
x = s.split('+')
print(x)
#['apple/SP', '', '/SW', 'orange/NNG', '', '/FG', 'melon/SL', 'food/JKG']
If split with a separator '++':
s = 'apple/SP++/SW+orange/NNG++/FG+melon/SL+food/JKG'
splitted_s = s.plit('++')
print(x)
#['apple/SP', '/SW+orange/NNG', '/FG+melon/SL+food/JKG']
I have no idea of how to come to the result of [('apple', 'SP'), ('+', 'SW'), ('orange', 'NNG'), ('+', 'FG), ('melon', 'SL'), ('food', 'JKG')]