Reputation:
I need to convert tuples into an array of strings with those tuples.
So this:
(A, "DEFAULT"), (B, "a$"), (C, "aa$"), (D, "(a|b|c)*aab(a|b|c)*")`
Should become this.
['(A, "DEFAULT")', '(B, "a$")', '(C, "aa$")', '(D, "(a|b|c)*aab(a|b|c)*")']
Upvotes: 0
Views: 83
Reputation: 507
string = '(A, "DEFAULT"), (B, "a$"), (C, "aa$"), (D, "(a|b|c)*aab(a|b|c)*")'
split = string.split('),')
result = []
for i in range(len(split)):
if i != len(split) - 1:
text = split[i] + ')'
result.append(text)
else:
result.append(split[i])
Got it!
Upvotes: 1