找出列表中最长的单词
al = ["hello", "world", "youyou", "responsibility"]
lenal = len(al[0])
tt=""
for i in al:
if len(i) > lenal:
tt = i
print(f"最长的单词是{tt}")
当然可以直接max
al = ["hello", "world", "youyou", "responsibility"]
print("最长的单词是"+max(al,key=len))
给定两个字符串,编写一个程序,确定其中一个字符串的字符重新排列后,能否变成另一个字符串
输如:st="abc",st2="bca",输出true
st="abc",st2="adc",输出false
st = input("请输入合理字符串")
st2 = input("请输入合理字符串")
print(sorted(st) == sorted(st2))