The Python Oracle

Python string comparison

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Track title: CC B Schuberts Piano Sonata No 16 D

--

Chapters
00:00 Question
01:28 Accepted answer (Score 8)
01:49 Answer 2 (Score 6)
02:03 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