🐍How to explain it⁉️🤔🤣🙃🤕 & more... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 20

🐍How to explain it⁉️🤔🤣🙃🤕 & more...

# SL PlayGound a = 300 b = 300 print(a is b) # True a, b = 300, 300 print(a is b) # False # True in Pycharm Python 3.8.0 Shell >>> a = 300 >>> b = 300 >>> a is b False >>> a, b = 300, 300 >>> a is b True >>> https://code.sololearn.com/che8Hyz22KLz/?ref=app

4th Dec 2019, 1:16 PM
Janusz Bujak 🇵🇱 🇺🇦
Janusz Bujak 🇵🇱 🇺🇦 - avatar
2 Answers
+ 6
The specification of Python says that with immutable numbers - like int - Python may secretly only store one value for all the occurrences of that string, but doesn't have to. In some cases you'll encounter two separate (equal) numbers, in other cases they may be only one number in memory. It doesn't matter and you don't have to give a heck. Only for mutable objects Python *has to* enforce separate objects, because you need to know (for example) which list you are filling with stuff right now.
4th Dec 2019, 5:12 PM
HonFu
HonFu - avatar
+ 12
HonFu Thanks for explanations‼️☺️ It all schows that 🐍 is dangerous & can bit you⁉️🤔🙃
4th Dec 2019, 8:42 PM
Janusz Bujak 🇵🇱 🇺🇦
Janusz Bujak 🇵🇱 🇺🇦 - avatar