【发布时间】:2016-02-17 14:20:50
【问题描述】:
我有
list1 = ["one", "two", "two", "three", "five", "five", "five", "six"]
输出应该是
list2 = ["five" , "two", "one", "three" , "six"]
-
"five"是第一个元素,因为在 list1 中出现的次数最多 (3) -
"two" 是第二个元素,因为在 list1 中的出现次数次之(2) -
"one"、"three" 和"six"的出现次数相同 (1),所以它们在我的list2中排在最后——只要它们在“五”之后,它们并不重要“两个”。list2 = ["five" , "two", "six", "three", "one"]或list2 = ["five" , "two", "three", "one", "six"]或任何其他变体都是可以接受的。
【问题讨论】: