Discuss / Python / 有一个循环的解法

有一个循环的解法

Topic source

talyerbooming

#1 Created at ... [Delete] [Delete and Lock User]

    if len(L) == 0:

        return(None,None)

    for x in L:

        if x == min(L):

           x1 = x 

    for y in L:

        if y == max(L):

           y1 = y

    return(x1,y1)

感觉你这个代码没什么意义,你都用了max() 和min() 函数了,还需要迭代什么呢?

这个作业就是要通过迭代找出最大值和最小值呀?


  • 1

Reply