13
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python2で(a == 1 and a == 2 and a == 3) を常にTrueと等しくする魔法の一文(演算子はいじらない系)(ソース4行)

Last updated at Posted at 2018-01-22

魔法の一文とはこれだ!

True = False

実際のコード

True = False
a = 0
if (a == 1 and a == 2 and a == 3) == True:
    print "Hello, False!"
Hello, False!

解説

Python2でTrueは予約語ではないので、Falseを代入できます。(a == 1 and a == 2 and a == 3)は何もしなければFalseなので、常にTrue(変数)の中身であるFalseに等しいです。

13
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?