题解 | #查找兄弟单词#
查找兄弟单词
http://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
python3简单快捷
做题思路
- 首先对于输入做处理,取得自己想要的值 split(‘ ’)根据一行中的空格,切割生成列表
- 列表下表取得自己想要的值
- 将输入的字符创排序后和X对比,排序后相同的但是没拍许前不同的是兄弟字符串
while True:
try:
lst = input().split(' ')
dic = []
x = lst[-2]
for i in lst[1:len(lst)-2]:
if sorted(i) == sorted(x) and i != x:
dic.append(i)
res = sorted(dic)
print(len(res))
print(res[int(lst[-1])-1])
except:
break