You can’t tell the reason just by taking screenshots of these contents. You can add a print in else, firstly to see if else is entered, but also to see what the word and key are.
What you see in the debuger of IDE may not be the real values. You can print out their type and have a look. You will find that debuger can sometimes lie. Also, you can look at the difference between __str__ and __repr__ and understand obj==eval(repr(obj)). Here’s a great answer: Difference between str and repr in Python
Print it out to see if there are any encoding problems in the local and Linux environments. After pasting down the code, do you want us to type it again by hand? . .
You can’t tell the reason just by taking screenshots of these contents.
You can add a print in else, firstly to see if else is entered, but also to see what the word and key are.
What you see in the
debuger
ofIDE
may not be the real values. You can print out their type and have a look.You will find that
debuger
can sometimes lie.Also, you can look at the difference between
__str__
and__repr__
and understandobj==eval(repr(obj))
.Here’s a great answer: Difference between str and repr in Python
Just use
==
to judge. . .Print it out to see if there are any encoding problems in the local and Linux environments. After pasting down the code, do you want us to type it again by hand? . .