Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

remove semicolon from end of string

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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(';')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading