• Martin Thoma
  • Home
  • Categories
  • Tags
  • Archives
  • Support me

Python Puzzle #3: Associativity

Contents

  • Python Puzzle #3: Associativity
    • Answer

What is the output of

1 in [] in "a"

and what is the output of

(1 in []) in "a"

or

1 in ([] in "a")

. . . . . . . . . . . . . . . . . . . . . . . . .

Answer

The first expression evaluates to False, because it gets evaluated as (1 in []) and ([] in 'a') (Manual, Source).

The second two expressions are invalid; they throw an error.


Published

Okt 2, 2012
by Martin Thoma

Category

Code

Tags

  • Programming 52
  • puzzle 22
  • Python 141

Contact

  • Martin Thoma - A blog about Code, the Web and Cyberculture
  • E-mail subscription
  • RSS-Feed
  • Privacy/Datenschutzerklärung
  • Impressum
  • Powered by Pelican. Theme: Elegant by Talha Mansoor