输入一串字符,检查是否可以组成friend
"""
输入一串字符,检查是否可以组成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的更多相关文章
- String字符串,输入一串字符判断其中数字,字母,其他的字符的个数
public class StringClassTest { public static void main(String[] args) { //遍历字符串 String str = "H ...
- 【Python练习1】统计一串字符中英文字母、空格、数字和其他字符的个数
练习思路: 1.输入一串字符 2.筛选出字符中的英文字母并统计 3.筛选出字符中的空格并统计 4.筛选出字符中的数字并统计 5.筛选出字符中的其他字符并统计 代码实现: def msg(s): abc ...
- C 输入一串数字,去掉当中含7的和能被7整除的数
C 输入一串数字,去掉当中含7的和能被7整除的数,每一个数小于10000,数字个数小于100 输入样例:1,7,56,77,87,2,45,42,97,9977 输出:1,2,45 注意:输入个数不确 ...
- Excel怎样从一串字符中的某个指定“字符”前后截取字符及截取字符串常用函数
怎么样可以从一串字符中的某个指定位置的前或后截取指定个数的字符. 如:12345.6789,我要截取小数点前(或后)的3个字符.怎么样操作, 另外,怎么样从右边截取字符,就是和left()函数相反的那 ...
- C++重载输入和输出操作符以及IO标准库中的刷新输入缓冲区残留字符问题
今天在做C++ Primer习题的14.11时,印象中应该挺简单的一题,结果却费了很长时间. 类定义: typedef string Date; class CheckoutRecord{ publi ...
- 写一个方法完成如下功能,判断从文本框textbox1输入的一个字符,如果是数字则求该数字的阶乘,如果是小写字条,则转换为大写,大写字符不变,结果在文本框textbox2中显示
窗体设计: 代码: using System; using System.Collections.Generic; using System.ComponentModel; using System. ...
- Eclipse 修改自动补全触发器只能输入四个字符为多个字符
如果eclipse中的[auto activation triggers for java]自动补全触发器这个位置的文本框有时候只能输入4个字符, 可以通过修改配置文件的方法实现,具体操作步骤如下: ...
- 把查询的结果组织为一串字符(eg:板板鞋,兵乓球,篮球,足球)
--把查询的结果组织为一串字符(板板鞋,兵乓球,篮球,足球) drop table a create table a( name varchar(20)) insert into a select ' ...
- java面试题:如果一串字符如"aaaabbc中国1512"要分别统计英文字符的数量,中文字符的数量,和数字字符的数量,假设字符中没有中文字符、英文字符、数字字符之外的其他特殊字符。
package com.swift; public class TotalNumber_String { public static void main(String[] args) { /* * 如 ...
随机推荐
- 兼容ie10及以上css3加载进度动画
html <div class="spinner"> <div class="rect1"></div> < ...
- linux网络设置和虚拟机克隆转移之后网卡找不到
linux网络设置和虚拟机克隆转移之后Error:No suitable device found:no device found for connection 'System eth0'问题解决 ...
- 百度接口test
https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=Mk2Orf5pqEOXvYR ...
- Elasticsearch6.13 升级6.24 单节点停机升级
Elasticsearch6.x 升级6.y 是支持滚动升级的,目前我们测试环境只有一个节点只能停机升级了 准备工作 禁用分片分配 curl -X PUT "localhost:9200/_ ...
- 【LeetCode每天一题】Substring with Concatenation of All Words(具备列表中所有单词的字串)
You are given a string, s, and a list of words, words, that are all of the same length. Find all sta ...
- [Java in NetBeans] Lesson 11. While Loops
这个课程的参考视频和图片来自youtube. 主要学到的知识点有:(the same use in C/C++) 1. while loop while(i < max){} will keep ...
- js简易计算器底层运算逻辑(带撤销功能)
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- 【漏洞公告】高危:Windows系统 SMB/RDP远程命令执行漏洞
2017年4月14日,国外黑客组织Shadow Brokers发出了NSA方程式组织的机密文档,包含了多个Windows 远程漏洞利用工具,该工具包可以可以覆盖全球70%的Windows服务器,为了确 ...
- python beautiful soup库的超详细用法
原文地址https://blog.csdn.net/love666666shen/article/details/77512353 参考文章https://cuiqingcai.com/1319.ht ...
- android 流程跟踪
#记录一下 Thread cur_thread = Thread.currentThread(); StackTraceElement stack[] = cur_thread.getStackTra ...