Python's equivalent of && (logical-and) in an if-statement

delete picture delete · Mar 21, 2010 · Viewed 2.2M times · Source

Here's my code:

def front_back(a, b):
  # +++your code here+++
  if len(a) % 2 == 0 && len(b) % 2 == 0:
    return a[:(len(a)/2)] + b[:(len(b)/2)] + a[(len(a)/2):] + b[(len(b)/2):] 
  else:
    #todo! Not yet done. :P
  return

I'm getting an error in the IF conditional.
What am I doing wrong?

Answer

ChristopheD picture ChristopheD · Mar 21, 2010

You would want and instead of &&.