首页 > 其他 > 详细

输入一串字符,检查是否可以组成friend

时间:2018-05-21 18:28:52      阅读:181      评论:0      收藏:0      [点我收藏+]
"""
输入一串字符,检查是否可以组成friend
"""


from collections import Counter


def foo(num_list):
for i in friend:
try:
num = count[i]
if num < num_list[0]:
num_list.pop()
num_list.append(num)
except KeyError as e:
print(‘输入的字符串不能组成friend。。。‘)
return False
return num_list


my_str = input(‘随意输入一串字符:‘)
count = dict(Counter(my_str))
friend = ‘friend‘
num_list = [len(my_str)]
if foo(num_list):
print(‘可以组成 {} 个friend!‘.format(num_list))

输入一串字符,检查是否可以组成friend

原文:https://www.cnblogs.com/changqing8023/p/9068465.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!