The Python Oracle

Python string comparison

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Book End

--

Chapters
00:00 Python String Comparison
01:06 Accepted Answer Score 8
01:21 Answer 2 Score 6
01:30 Thank you

--

Full question
https://stackoverflow.com/questions/2516...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #string #compare

#avk47



ACCEPTED ANSWER

Score 8


Are you sure that there isn't a terminating line feed character, making your string contain "true\n"? That seems likely.

You could try return isdeployed.startswith("true"), or some stripping.




ANSWER 2

Score 6


Have you tried to call

isdeployed.strip()

before the comparision