m0_70373645
2022-05-07 23:01
采纳率: 77.8%
浏览 29
已结题

python中for循环怎么改成while循环?

以下代码怎么改成while循环?

def maxnum(lst):
maxn = 0
for i in lst:
if maxn < i:
maxn = i
return maxn
def minnum(lst):
minn = lst[0]
for i in lst:
if minn > i:
minn= i
return minn
a = [3,4,6,7]
print(maxnum(a) - minnum(a))

2条回答 默认 最新

相关推荐 更多相似问题