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]

 

转载于:https://www.cnblogs.com/bamboozone/p/10590697.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值