社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

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

Fraim_rus • 3 年前 • 1361 次点击  

因此,用户在一个字符串中输入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
 
1361 次点击  
文章 [ 1 ]  |  最新文章 3 年前