1
我正在写一个程序,它需要确定数字的范围,就像我在user_input'a'中放置15一样,所以它应该打印范围从'a'到'b',但不幸的是我是无法解决任何人都可以请帮助我。这是我的代码:Python范围问题
a = int(raw_input("How many did you say you're going to count down? "))
b = int(raw_input("When are you actually going to stop? "))
i = 0
for i in range(a, b):
i = i + 1
print i
,我希望它是这样工作的:
How many did you say you're going to count down? 15
When are you actually going to stop? 8
15
14
13
12
11
10
9
8
OR
How many did you say you're going to count down? 6
When are you actually going to stop? 4
6
5
4
nah bro它没有:/ – rocker789
@ rocker789:现在确实如此。你的循环正在向上计数(两次)。 –
该范围内应该是b + 1吗? –