def main():
line = input("How many numbers are included? \n")
numbers_included = int(line)
i = 0
sum = 0
print("Each number should be placed on separate row")
while i < numbers_included:
line = input ("")
number = int(line)
sum = sum + number
i = i + 1
average = sum/numbers_included
print("Average is",average)
print("and the biggest digit is", max(number))
main()
如何將最大數字打印到上面的代碼中?如何在python中使用max命令或類似的「inside」命令?
在此先感謝!
有沒有需要調用'len';你已經知道有多少數字('n_lines')。 – chepner
當然,你知道他們應該是平等的。儘管如此,len呼叫是不變的,這意味着平均值實際上是列表中的內容的平均值。否則,我們知道這是一個意味着提供了len == n _...但這是一個間接邏輯層次。 –