zoukankan      html  css  js  c++  java
  • 每日练习④:likes

    # Author:q1.ang
    '''
    def likes():
        # 输入代码实现以下的内容
        #
        # likes [] // must be "no one likes this"
        # likes ["Peter"] // must be "Peter likes this"
        # likes ["Jacob", "Alex"] // must be "Jacob and Alex like this"
        # likes ["Max", "John", "Mark"] // must be "Max, John and Mark like this"
        # likes ["Alex", "Jacob", "Mark", "Max"] // must be "Alex, Jacob and 2 others like this"
    '''
    
    def likes(names):
        if  len(names) == 0:
            print('no one likes this')
        elif len(names) == 1:
            print('%s likes this'%names[0])
        elif len(names) ==2:
            print('%s and %s like this'%(names[0],names[1]))
        elif len(names) == 3:
            print('%s,%s and %s like this'%(names[0],names[1],names[2]))
        else:
            print('%s,%s and %d others like this'%(names[0],names[1],len(names) - 2))
    
    
    likes([])
    likes(["Peter"])
    likes(["Jacob", "Alex"])
    likes(["Max", "John", "Mark"])
    likes(["Alex", "Jacob", "Mark", "Max"])
  • 相关阅读:
    契约测试SpringCloud Contract入门
    CircuitBreaker 组件 resilience4j
    阿里开源的15个顶级Java项目
    将军令:数据安全平台建设实践
    ResNet
    设计模式
    muduo评测摘要
    muduo 学习
    RAII
    大数据框架
  • 原文地址:https://www.cnblogs.com/q1ang/p/9352146.html
Copyright © 2011-2022 走看看