Py学习  »  Python

在Python中使用range()模块时,这个看似无关紧要的数字从哪里来?[副本]

Leo • 1 年前 • 883 次点击  

我被要求创建两个输入变量(低和高),并输出两者之间的奇数。我决定使用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
 
883 次点击  
文章 [ 2 ]  |  最新文章 1 年前