- 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.
推薦閱讀
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- PowerCLI Cookbook
- Java編程指南:基礎(chǔ)知識、類庫應(yīng)用及案例設(shè)計(jì)
- Julia Cookbook
- Java EE 8 Application Development
- MATLAB for Machine Learning
- Spring快速入門
- Android系統(tǒng)原理及開發(fā)要點(diǎn)詳解
- Hands-On Neural Network Programming with C#
- OpenCV 3計(jì)算機(jī)視覺:Python語言實(shí)現(xiàn)(原書第2版)
- Application Development with Swift
- Arduino Electronics Blueprints
- Ubuntu Server Cookbook
- 計(jì)算機(jī)軟件項(xiàng)目實(shí)訓(xùn)指導(dǎo)
- 流暢的Python