伙计们,我想按照用户输入值的升序和降序对预定义列表进行排序。它假设从用户处获取一个最大值和最小值,并在列表中查看这些值,然后按升序和降序打印。IDK如何使用范围函数来完成这个任务,所以如果有人可以帮助,请:D这里是我做的代码,并希望使用该列表
userInputMax = input("Please enter max value")
userInputMin = input("Please enter min value")
priceList = [399, 4369, 539, 288, 109, 749, 235, 190, 99, 1000]
print(priceList)
如果用户说最大值为1000,最小值为99,那么输出应该类似于99、109、235、288、399、539、749、1000
如果您试图使列表包含从最小到最大的数字,那么您可以使用列表理解创建一个列表,使用范围函数包含从最小到最大的所有数字
这个怎么样
这就是你要找的吗
相关问题 更多 >
编程相关推荐