zoukankan      html  css  js  c++  java
  • kaggle learn python

    def has_lucky_number(nums):
        return any([num % 7 == 0 for num in nums])
    def menu_is_boring(meals):
        """Given a list of meals served over some period of time, return True if the
        same meal has ever been served two days in a row, and False otherwise.
        """
        for meal in meals:
            next = meals.index(meal)+1
            try:
                if meal == meals[next] :
                    return True
            except:
                    return False 
    #     else:
    #         return False
    meals=['Spam', 'Eggs', 'Bacon', 'Spam']
    menu_is_boring(meals)
    为什么不能返回数据啊!!!
    竟然用len(meals)-1来解决了。。。。
    str = "123abcrunoob321"
    print (str.strip( '12' )) 
    result:
    3abcrunoob3
    以上下例演示了只要头尾包含有指定字符序列中的字符就删除
    map(lambda x:x.strip(',.'),doc.lower().split())

    dic 没有append 方法
    #         2 decimal points   3 decimal points, format as percent     separate with commas
    "{} weighs about {:.2} kilograms ({:.3%} of Earth's mass). It is home to {:,} Plutonians.".format(
        planet, pluto_mass, pluto_mass / earth_mass, population,
    )
    result:
    "Pluto weighs about 1.3e+22 kilograms (0.218% of Earth's mass). It is home to 52,910,390 Plutonians."
     
    ['K']
    [10 if x in'KQJ' else x for x in hand_1]
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- focus on what you want to be
  • 相关阅读:
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
  • 原文地址:https://www.cnblogs.com/bamboozone/p/10590697.html
Copyright © 2011-2022 走看看