- Hands-On Data Science and Python Machine Learning
- Frank Kane
- 145字
- 2021-07-15 17:15:02
Iterating through entries
for ship in captains:
print (ship + ": " + captains[ship])
The output of the above code is as follows:

Let's look at a little example of iterating through the entries in a dictionary. If I want to iterate through every ship that I have in my dictionary and print out captains, I can type for ship in captains, and this will iterate through every single key in my dictionary. Then I can print out the lookup value of each ship's captain, and that's the output that I get there.
There you have it. This is basically the main data structures that you'll encounter in Python. There are some others, such as sets, but we'll not really use them in this book, so I think that's enough to get you started. Let's dive into some more Python nuances in our next section.
推薦閱讀
- INSTANT Mock Testing with PowerMock
- Vue.js 2 and Bootstrap 4 Web Development
- Oracle Database In-Memory(架構與實踐)
- 實戰Java程序設計
- Python測試開發入門與實踐
- Web開發的貴族:ASP.NET 3.5+SQL Server 2008
- The React Workshop
- HTML5+CSS3+JavaScript Web開發案例教程(在線實訓版)
- Building a Quadcopter with Arduino
- Modern JavaScript Applications
- 高級語言程序設計(C語言版):基于計算思維能力培養
- C#開發案例精粹
- 從零開始學Python網絡爬蟲
- SQL Server 2016 從入門到實戰(視頻教學版)
- Bootstrap for Rails