A string can be with both single
'_' and double
'__' underscore characters at the end. Checking it with :
if myString[-1]=='_': pass
works only for a single character. How to achieve the same using one line?
(only if last character(s)=='_' or '__').
Best How To :
For Python version > 2.5,
You can use
endswith with a tuple
underscores = ('_', '__')
if myString.endswith(underscores): pass
>>> underscores = ('_', '__')
>>> xx = "text__"
>>> xxx = "text_"