fogbit fogbit - 1 year ago 212
Python Question

input() vs

import sys
s1 = input()
s2 =

#type "s" for example

s1 == "s" #False
s2 == "s" #True

Why? How can I make
to work properly?
I tried to encode/decode
, but it doesn't work.

Thank you.

Answer Source

If you're on Windows, you'll notice that the result of input() when you type an 's' and Enter is "s\r". Strip all trailing whitespace from the result and you'll be fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download