Python 相当于 &&(逻辑与)在 if 语句中 [英] Python's equivalent of && (logical-and) in an if-statement

查看:21
本文介绍了Python 相当于 &&(逻辑与)在 if 语句中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

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

我在 IF 条件中遇到错误.
我做错了什么?

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

推荐答案

您需要 and 而不是 &&.

这篇关于Python 相当于 &&(逻辑与)在 if 语句中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆