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?
Two comments:
and
andor
for logical operations in Python.You would want
and
instead of&&
.Use of "and" in conditional. I often use this when importing in Jupyter Notebook:
Probably this is not best code for this task, but is working -
A single
&
(not double&&
) is enough or as the top answer suggests you can use 'and'. I also found this in pandasif we replace the "&" with "and", it won't work.
I went with a purlely mathematical solution: