Just explain me how it is possible:
сhar = input()
print(char)
Traceback (most recent call last): File "test.py", line 2, in print(char) NameError: name 'char' is not defined
To make things more interesting, consider running that code in repl.it with double-checked python version:
import sys
print(f'Python version on this machine:\n{sys.version}')
сhar = input()
print(char)
Python version on this machine:
3.7.4 (default, Jul 13 2019, 14:20:24)
[GCC 6.3.0 20170516]
type anything
Traceback (most recent call last):
File "main.py", line 5, in
print(char)
NameError: name 'char' is not defined
Unicode identifier names.
>>> "char" == "сhar"
False
One of those c is a vanilla 'LATIN SMALL LETTER C' but the other is chr(0x441)
, i.e. 'CYRILLIC SMALL LETTER ES'. On a typical machine they will render to the terminal with very similar looking (or exactly same) glyphs.
Your char = input()
contains the cyrillic character с (see here)
Whereas the print(char)
is purely latin.
This also reminds me of the greek question mark prank, where the characters for semicolon and the question mark are rendered almost the same: ;;
Edit: wim was faster
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With