鱼C论坛

 找回密码
 立即注册
查看: 7714|回复: 38

[技术交流] Python: 每日一题 34

[复制链接]
发表于 2018-5-17 19:54:48 | 显示全部楼层
  1. def longest_consec(listr,n):
  2.     n_list = []
  3.     for i in range(len(listr)):
  4.         temp = [len(listr[i]),listr[i]]
  5.         n_list.append(temp)
  6.         temp = []
  7.     n_list.sort(reverse=True)
  8.     result = ('')
  9.     time = 0
  10.     while time != n :
  11.         result += str(n_list[time][1])
  12.         time += 1
  13.     print(result)
  14.         

  15. longest_consec(["zone", "abigail", "theta", "form", "libe", "zas", "theta", "abigail"], 2)  
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-24 03:14

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表