Mia L 2022-04-10 15:47 采纳率: 70%
浏览 39
已结题

请问怎样才能让a in b得出True


s=""
a=['1','2']
for i in a:
    s+=i
b=['1','2','3']
a in b

具体题目在下方


def cookable_recipes(ings, recipes):
    """
    >>> rec = {'Egg Fried Rice': ['egg', 'rice', 'msg'], \
'Spaghetti': ['noodle', 'tomato sauce'], 'Steamed Rice': ['rice']}
    >>> cookable_recipes(['egg', 'msg', 'rice'], rec)
    ['Egg Fried Rice', 'Steamed Rice']
    >>> cookable_recipes(['egg', 'rice', 'msg', 'noodle', 'tomato sauce'], rec)
    ['Egg Fried Rice', 'Spaghetti', 'Steamed Rice']
    >>> cookable_recipes(['egg'], rec)
    []

    """
    keys = [i for i in recipes] 
    values=list(recipes.values())
    result=[]
    for i in values:
        if i in ings:
            result.append(i)
    return result
  • 写回答

3条回答 默认 最新

  • 陈年椰子 2022-04-10 16:02
    关注
     
    s=""
    a=['1','2']
    for i in a:
        s+=i
    b=['2','3','1']
    a in b
    
    

    这样 a in b 是True 吗?

    如果是True , 那就遍历a,判断a的元素都在b 里就返回True

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 4月18日
  • 已采纳回答 4月10日
  • 创建了问题 4月10日

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分