社区所有版块导航
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中使用range()模块时,这个看似无关紧要的数字从哪里来?[副本]

Leo • 9 月前 • 135 次点击  

我被要求创建两个输入变量(低和高),并输出两者之间的奇数。我决定使用range()模块,并将3作为低值,将7作为高值。该程序预计只返回5个,但返回了5个和3个。 我在下面放了一张终端的屏幕截图。 click here to see

low = int(input("enter the first number: "))
high = int(input("enter the second number: "))

def program(low, high):
    numbers = range(low, high, 2)
        
    for n in numbers:
        print(n)
        

program(low, high)

那我该怎么修呢?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/160043
 
135 次点击  
文章 [ 2 ]  |  最新文章 9 月前