题解 | #查找兄弟单词#心路历程
查找兄弟单词
https://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
temp1 = input().split() n = int(temp1.pop(0)) k = int(temp1.pop()) x = temp1.pop() #不需要找到所有的兄弟单词,只需要找到存在于字典中的兄弟单词——全部的兄弟单词咋找啊😭 a = [] # sorted(temp1) 无法用这种方式对列表进行排序——有返回值呀!😄 # print(temp1) for i in temp1: if sorted(i) == sorted(x) and i!= x: a.append(i) print(len(a)) a.sort() #当列表元素为字符串时候,默认按字典顺序排序 但为什么sorted(a)不行呢——sorted返回新列表——哈哈😄 #b = sorted(a) if k <= len(a): print(a[k-1])