Py学习  »  Python

有没有办法让Python找到用户输入列表中概率最高的下一个数字?

Fraim_rus • 3 年前 • 1450 次点击  

因此,用户在一个字符串中输入n个数字的列表(不超过1000),程序会找到并输出下一个出现概率最高的数字。我是一个初学者,一直在计算可编程性,Python不允许我将列表元素和使用的方法都转换为int:


n = [int(input()), int(input()), int(input()), int(input()), int(input())]
for i in n:
    P = collections.Counter([i]) / len(n)
    print(P)  # The program is supposed to determine the highest possibility and print the respective number afterwards
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/129437
 
1450 次点击  
文章 [ 1 ]  |  最新文章 3 年前