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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM