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

casting to int python with symbol

so I want to cast these to ints but when I use the built-in function int() I get an error, I don’t want to make a custom function that checks the first character,so I was wondering if there was a way to convert these to ints.

error
strings

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

>Solution :

From what we found in the discussion under your question:

You have the mathematical unicode symbol "minus sign" instead of the ASCII symbol "hyphen-minus" in your string.

The problem can be solved by replacing the non-workning symbol with the working one:

int(CDMAOutput[idx].replace(chr(8722), '-')))
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