猿问

各位大佬看看这个问题,Python怎么解决这个需求?

需求:1.由用户输入输入一串字符,通过程序筛选出这个字符串是否含有'f','r','i','e','n','d',有的话拼接起来组成‘friend’,并且打印到屏幕上。

          2.统计出这一串字符可以组成几个'friend'。


阿青叫我少哔哔
浏览 1508回答 1
1回答

慕移动0252285

zifu=input("Please input your zifu:")a=zifu.count("f")b=zifu.count("r")c=zifu.count("i")d=zifu.count("e")e=zifu.count("n")f=zifu.count("d")g=[a,b,c,d,e,f]h=min(g)print(h*"frined")

慕设计2395807

DZORURUJZWFHGMCZQZKXAFZORRFXAUKKWTZQNGHUNQAWJSIIBPFXAAPPCVEXLIOHREMBHQKJZMIBRMFOERHEBEKQRAMFLUEAHXZCIJCSCICYHDNQVVICWEYRKZFKFIEAUQYEDMNZDJJMCZIZCZFTZTZMMSXTSBQKDJPCSDDJMPXNBHNTNWTBIPYZSSXZCSIOLIVRIHDJSYOOFMVAJMIBXNUKWMGVBKQNZPFIPFIKDAQDGNBHRQNACRRLUEYYDFQZUAHRHNNJSFORHXEISSVDJDNQZZAXGNJFBIHEOVLEEAMSIISOIERFJFLVCJWKDJMFLRBEOQWMCSAGKCLVILOHUREBRHERKKUDETWMNWWFUUALHASTTPMPVVUMZXGMMPMSCQZCVICOISDCXAZCFCDHEYRGWMCBIOUJGPABBEXNQQQGJWFEEISYILDPIFIISILFBVUSEFNMZTKGATRHGGJZWTKEAKCZSOERHHBADSIIIVOERRKBNGGMOYEBKUKJMPSSPSSCDMHTJZNDAVOIYUZZYCZTDJZEHHHDQNTTDWATEAGGQJWMUCLJSYLYMSSCBUQODXTJPHAILEBRYUFFOOKDNNTKKNXXQQNMSPTWJPPFWZOYUEKQTDWJTMDWFFOVIBFLJPCNGKNDXLKDKDGJMFSITGTCQGGOBBAWFWPCWJCPPVYNDSPLBKGVSHQMVLAQTCSBIXNWSPLBXUKGVRTKGXNJFBACTOSNDADAPAQZVTCFVROKWSCMIYUCFOEZPRNDMVYUKGDTQGILOEUKTKZWFCEHXAQTMIXODGDFVLAUDZCGVRUCFOIYURNJMOKNQNPLUDSULUQANQXTJSCSHKAUQMWMWSBRORXGIFIYGQTIFKBDTWFIRHWF

carolcoral

第一个要求用正则匹配来过滤,第二个也可以用正则匹配,然后count++
随时随地看视频慕课网APP

相关分类

Python
我要回答