fork download
  1. words=['python','ai','machine learning','data','nlp']
  2. longest=words[0]
  3. for w in words:
  4. if len(w)>len(longest):
  5. longest=w
  6. print(f"最长的字符串是'{longest}',长度为{len(longest)}")
Success #stdin #stdout 0.1s 14128KB
stdin
Standard input is empty
stdout
最长的字符串是'machine learning',长度为16