I want to remove semicolon from the end of a string in python:
mystring = 'NM_000106.5:c.985+39G>A;c.886C>T;c.1457G>C;'
I tried something like this:
clean_end = mystring[:-1] if mystring.endswith(';') else mystring
However in this case, mystring.endswith(';') returns False.
Why is this?
>Solution :
You’re not using a regular ;, but a greek question mark (;).
| Name | Char | Hex |
|---|---|---|
| greek question mark | ; |
0x37e |
| semicolon | ; |
0x3b |
So change the endswith param to the correct one:
mystring.endswith(';')