【发布时间】:2017-09-26 21:36:08
【问题描述】:
我正在做一个 python 练习,要求 编写读取整数输入序列并打印的 Python 程序
The smallest and largest of the inputs.
到目前为止我的代码
def smallAndLarge():
num1 = int(input("Enter a number: "))
num2 = int(input("Enter a number: "))
if num1 > num2:
print(num1,"is the largest number, while",num2,"is the smallest number.")
else:
print(num2,"is the largest number, while",num1,"is the smallest number.")
smallAndLarge()
我正在使用 def smallAndlarge():因为我的导师希望我们将来对所有程序都使用 def 函数。
我的问题是如何向用户请求多个输入,直到他们决定不再添加输入。感谢您的宝贵时间。
【问题讨论】:
-
阅读
while循环:wiki.python.org/moin/WhileLoop
标签: python loops python-3.6