题目描述: 两个字符串 input1和字符串input2,字符串中元素的值域是26个大写字母,判断input2中所有字符是否都包含在字符串input1中,包含返回 true,否则返回 false, 代码如下:(python 3) def func(s1,s2):     length1 = len(s1)     length2 = len(s2)     if length1 <5 or length2 <5:         return False     if length1 < length2:         return False     list1 = [0]*26     list2 = [0]*26     index = 0     for i in range(length1):         asci_num = ord(s1[i])         if asci_num  <65 or  asci_num > 90:             return False         index = ord(s1[i])-65         list1[index] =1     for i in range(length2):         asci_num = ord(s2[i])         if asci_num  <65 or  asci_num > 90:             return False         index = ord(s2[i])-65         list2[index] =1     for i in range(26):         if list2[i] > list1[i]:             return False     return True if __name__ == '__main__':     s1 = input('input first str:')     s2 = input('input second str:')     print (func(s1,s2))
点赞 评论

相关推荐

09-24 18:30
已编辑
长春工业大学 产品经理
小肥罗:HR就是好人的缩写哈哈哈哈
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务