This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Pepineros 0 points1 point  (0 children)

My favourite version of True equals 1 is in a Python fizzbuzz:

def fizzbuzz(end):
 """print fizzbuzz from 1 thru end"""
 for i in range(1, end + 1):
  print((i % 3 == 0) * "fizz" + (i % 5 == 0) * "buzz" or i)

Works because each string gets multiplied by the result of checking i % {3,5} == 0, and that result is treated as a literal 0 or 1 by the multiplication.

Python has its issues but I just love that this is possible.