let’s say you have the strings
s1 = "('element1', 'element2', 'element3')"
and
s2 = "(1A, 2A, 3A)"
Is there a simple technique you can use to convert
s1 to "(element1, element2, element3)"
and
s2 to "(1, 2, 3)"
For s1, every single-quotation mark needs to disappear, and for s2 each A should disappear. What’s the most straightforward way to do this and only this?
EDIT -> everything within quotation marks is part of the whole string… there are no tuples nor any variables. Thanks!
I assume
s1ands2are supposed to be the stringsTo remove all single quotes from
s1, you can useTo remove all occurrences of the letter
Afroms2, useNote that strings can’t be modified in place (they are immutable) —
str.replace()will return a new string.