wenwen
wenwen

探索網路世界和進入區塊鏈的過程或許很平凡,但我就是想分享給大家,若能幫助到有需要幫助的人,那就更好了。 有幫到你的話,記得按下方拍手圖,不需花你任何金錢,免費註冊Liker ID,就可對我化讚為賞:https://button.like.co/willie5068

💛010第七章 USER INPUT AND WHILE LOOPS

input() 總是搭配 while Loop 使用。

💛20230110晨讀感言:

💔既然有了 for loop,為什麼還要再使用 while loop 呢?若是對這兩種 迴圈 的意義不清楚的話,是很難在後續 寫程式 時做出最適當的選擇(==當然這兩種迴圈也可以合併使用==)。而在本章中124頁有對這個問題做出明確的答覆。

💔break 適用在 任何迴圈,而 continue 也是如此,不過,在迴圈中, 使用 continue 時具有 ingore the rest loop program 並跳到 迴圈的開始 繼續 執行,並不像 字面上 只有 一種「繼續」的含意。

💛晨讀摘要:

💚122 Rather than breaking out of a loop entirely without executing the rest of its code, you can use the continue statement to return to the beginning of the loop based on the result of a conditional test.

💚124 A for loop is effective for looping through a list, but you shouldn’t modify a list inside a for loop because Python will have trouble keeping track of the items in the list. ==To modify a list as you work through it, use a while loop==. Using while loops with lists and dictionaries allows you to collect, store, and organize lots of input to examine and report on later.

from :《python crash course》

CC BY-NC-ND 2.0 版权声明

喜欢我的文章吗?
别忘了给点支持与赞赏,让我知道创作的路上有你陪伴。

加载中…
加载中…

发布评论