Task08:模块与datatime

了解Collection模块,编写程序以查询给定列表中最常见的元素。

题目说明:

输入:language = [‘PHP’, ‘PHP’, ‘Python’, ‘PHP’, ‘Python’, ‘JS’, ‘Python’, ‘Python’,‘PHP’, ‘Python’]

输出:Python

"""
Input file
language = ['PHP', 'PHP', 'Python', 'PHP', 'Python', 'JS', 'Python', 'Python','PHP', 'Python']
   
Output file
Python
"""
def most_element(language):
    """ Return a list of lines after inserting a word in a specific line. """
   


def most_element(language):
    """ Return a list of lines after inserting a word in a specific line. """
    count = 0
    unique = set(language)
    for u in unique:
        if language.count(u) > count:
            count = language.count(u)
            max_elem = u
    
    return max_elem

language = ['PHP', 'PHP', 'Python', 'PHP', 'Python', 'JS', 'Python', 'Python','PHP', 'Python']
print(most_element(language))


'Python'

你可能感兴趣的:(Task08:模块与datatime)