好吧,所以我在Python中练习循环,我在想如何让用户输入10个整数,然后它会输出最小的一个。我想知道如何与例如while循环做到这一点:Python中的循环(输出最小的输入)
Smallest = 0
count = 0
while count < 10:
Number = int(input("Enter a number >> "))
if Number < Smallest:
Smallest = Number
count = count + 1
print("{0} is the biggest value you have entered".format(Smallest))
但我怎么做一个for循环的格式?这是我到目前为止有:
for i in range(10):
Number = int(input("Enter a Number >> "))
if Number < Smallest:
Smallest = Number
print("{0} is the smallest value you have entered.".format(Smallest))
'min(int(input(“Enter a Number >>”))for i in range(10))' –
@Chris_Rands你应该给出答案而不是评论,因为它看起来很漂亮: D –