0

What is the python way to do this equivalent of this Perl line?

! (90 % 15) && print "yes"

GL2014
  • 6,016
  • 4
  • 15
  • 22

1 Answers1

1

You can write

not (90 % 15) and print("yes")

If you use python 2 (and >= 2.6), you need to explicitly import print_function

from __future__ import print_function

This is needed because the right operand of the boolean and need to be an expression (and can not be a statement). In python2, print is a statement, thus you need to import the print function from python3, available in the __future__ module. Note that you could also use sys.stdout.write("yes\n") to achieve the same goal.

Community
  • 1
  • 1
FabienAndre
  • 4,514
  • 25
  • 38