Загрузка...

Why a == b is True But a is b is False in Python 🤯 Python Trap Explained #shorts #coding #python

Ever tried a = 257; b = 257; print(a == b) in Python and saw True? But when you did print(a is b), it said False? Here's why: Python only caches small integers from -5 to 256. Values like 257 are stored as different objects. So == checks if values match, while is checks memory reference. This is one of the most common Python gotchas — don’t let it trip you in your next interview!

👉 Follow @CodeSnap-UR for more Python tricks and coding hacks!

Видео Why a == b is True But a is b is False in Python 🤯 Python Trap Explained #shorts #coding #python канала CodeSnap
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять