a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
if a > b:
i = a
while i < b+1:
print(i,end=" ")
i += 1
elif a < b:
i = b
while i <a+1:
print(i,end=" ")
i += 1
要求输入数字,然后按从大到小去排列数字,写出代码后输入数字,什么都输出不出来,也没有报错。
你题目的解答代码如下:
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
if a < b: # 这里是 a < b
i = a
while i <= b:
print(i,end=" ")
i += 1
elif a >= b: # 这里是 a >= b
i = b
while i <= a:
print(i,end=" ")
i += 1
如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!
,