freeCodeCamp/curriculum/challenges/chinese-traditional/07-scientific-computing-wit.../python-for-everybody/iterations-loop-idioms.md

733 B

id title challengeType videoId bilibiliIds dashedName
5e7b9f070b6c005b0e76f05e 迭代:循環成語 11 AelGAcoMXbI
aid bvid cid
334491369 BV1tw411R7Mm 376530765
iterations-loop-idioms

--question--

--text--

以下是一個如何在一串數值中找到最小的數值的代碼。 一行代碼有錯誤,導致整個代碼無法和預期一樣的運行。 那麼是哪一行?

smallest = None
print("Before:", smallest)
for itervar in [3, 41, 12, 9, 74, 15]:
    if smallest is None or itervar < smallest:
        smallest = itervar
        break
    print("Loop:", itervar, smallest)
print("Smallest:", smallest)

--answers--

3


4


6


7

--video-solution--

3