python 字符串字符匹配

 

地址:https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93?tpId=37&tqId=21304&rp=1&ru=%2Fta%2Fhuawei&qru=%2Fta%2Fhuawei%2Fquestion-ranking&tab=answerKey

 

 1 '''
 2 题目描述
 3 判断短字符串中的所有字符是否在长字符串中全部出现。
 4 请注意本题有多组样例输入。
 5 
 6 
 7 
 8 输入描述:
 9 输入两个字符串。第一个为短字符串,第二个为长字符串。两个字符串均由小写字母组成。
10 
11 输出描述:
12 如果短字符串的所有字符均在长字符串中出现过,则输出true。否则输出false。
13 
14 示例1
15 输入
16 bc
17 abc
18 输出
19 true
20 '''
21 
22 while True:
23     try:
24         n = input()
25         m = input()
26     except:
27         break
28     nl = list(n)
29     ml = list(m)
30     res = 'true'
31     for i in nl:
32         if i not in ml:
33             res = 'false'
34     print(res)

 

posted @ 2021-05-01 21:07  菜小鱼~  阅读(2626)  评论(0编辑  收藏  举报