I'm trying to catch strings with this condition:
if '_prod' in key:
But my string looks like "mystring_non-prod" and is catched by the if
condition.
And I have something weird if I print the variable:
key = 'mystring_non-prod'
if '_prod' in key:
name=key.strip('_prod')
print(name)
In [1]:
mystring_non-
(I know I should use something else then str.strip())
It looks like the "_" (underscore) is not reconize by if
.
So I expect not to catch "mystring_non-prod" and catch then "mystring_prod" and correctly format the string.
key = 'mystring_prod'
if '_prod' in key:
name=key.strip('_prod')
print(name)
In [1]:
mystring