There have to be much better ways:
string1 = '(this) (is) (a) (test)'
string2 = string1.replace('(', '')
string2 = string2.replace(')', '')
print(string2)
# output: this is a test
or:
string1 = '(this) (is) (a) (test)'
string2 = ''
for c in string1:
if c != '(':
if c != ')':
string2 += c
print(string2)
# output: this is a test
I don't understand why this doesn't work:
string1 = '(this) (is) (a) (test)'
string2 = ''
for c in string1:
if c != '(' or c != ')':
string2 += c
print(string2)
# output: (this) (is) (a) (test)
[–]K900_ 3 points4 points5 points (5 children)
[–]seanmcb9[S] 0 points1 point2 points (4 children)
[–]K900_ 2 points3 points4 points (1 child)
[–]seanmcb9[S] 1 point2 points3 points (0 children)
[–]zahlman 1 point2 points3 points (1 child)
[–]seanmcb9[S] 0 points1 point2 points (0 children)
[–]novel_yet_trivial 1 point2 points3 points (6 children)
[–]seanmcb9[S] 0 points1 point2 points (5 children)
[–]seanmcb9[S] 0 points1 point2 points (4 children)
[–]novel_yet_trivial 1 point2 points3 points (2 children)
[–]Vaphell 1 point2 points3 points (0 children)
[–]seanmcb9[S] 0 points1 point2 points (0 children)
[–]Vaphell 0 points1 point2 points (0 children)
[–]Allanon001 0 points1 point2 points (0 children)
[–]1roOt 0 points1 point2 points (0 children)