Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (1.6k points)

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?

2 Answers

0 votes
by (25.1k points)

You can simply use the keyword' and in place of && operator.

0 votes
by (106k points)
edited by

While in Python for logical and we use ‘and’ keyword and for logical or we use ‘or’ keyword.

Example:-

if foo == 'abc' and bar == 'bac' or zoo == '123':

To know more about this you can have a look at the following video tutorial:-

Interested to learn more about Python? Come & join our Python online course

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
asked Sep 25, 2019 in Python by Sammy (47.6k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...