An AI explained Python's is and == in four lines. One of them is wrong.

2026-10-17来源 dev.to ProgrammingEnglish

We asked Aria, our AI, how is and == differ in Python. She answered in four lines and sounded completely sure:

1. == checks whether two values are equal. 2. is checks whether two names point to the same object. 3. [] == [] is True. 4. [] is [] is also True, because both lists are empty. 

One line is wrong. Think before you scroll.

.

.

.

.

.

It's line 4. Each [] builds a new list, so you get two separate objects and [] is [] is False. Being empty doesn't make them the same object. That's also why you write x is None but compare lists with ==.

We turned this kind of thing into a free game. Aria answers a coding question in 5 or 6 lines and you tap the one that's wrong, then pick why. Five rounds take about five minutes on a phone.

Our October event closes Monday 19 Oct at 11:59 pm IST, and the top 10 get LogicWiz goodies delivered home.

Play it here: https://arena.logicwiz.ai/club/BJSRBK?utm_source=devto

Did line 4 fool you?

原文:https://www.a8q9.cn/en/article/an-ai-explained-python-s-is-and-in-four-lines-one-of-them-is-wrong-fc2c57.html

相关文章