- Hands-On Data Science and Python Machine Learning
- Frank Kane
- 191字
- 2021-07-15 17:15:01
Complex data structures
You can also have complex data structures with lists. So you don't have to just put numbers in it; you can actually put strings in it. You can put numbers in it. You can put other lists in it. It doesn't matter. Python is a weakly-typed language, so you can pretty much put whatever kind of data you want, wherever you want, and it will generally be an OK thing to do:
y = [10, 11, 12]
listOfLists = [x, y]
listOfLists
In the preceding example, I have a second list that contains 10, 11, 12, that I'm calling y. I'll create a new list that contains two lists. How's that for mind blowing? Our listofLists list will contain the x list and the y list, and that's a perfectly valid thing to do. You can see here that we have a bracket indicating the listofLists list, and within that, we have another set of brackets indicating each individual list that is in that list:
[[ 1, 2, 3, 4, 5, 6, 7, 8, 9 ], [10, 11, 12]]
So, sometimes things like these will come in handy.
- Vue.js快速入門與深入實(shí)戰(zhàn)
- Jenkins Continuous Integration Cookbook(Second Edition)
- Learning Probabilistic Graphical Models in R
- IBM Cognos Business Intelligence 10.1 Dashboarding cookbook
- Android傳感器開發(fā)與智能設(shè)備案例實(shí)戰(zhàn)
- PHP 7從零基礎(chǔ)到項(xiàng)目實(shí)戰(zhàn)
- Arduino Wearable Projects
- Java程序設(shè)計(jì)教程
- 快樂(lè)編程:青少年思維訓(xùn)練
- Java設(shè)計(jì)模式深入研究
- C語(yǔ)言程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)
- 流暢的Python
- JavaWeb入門經(jīng)典
- 區(qū)塊鏈原理與技術(shù)應(yīng)用
- Java無(wú)難事:詳解Java編程核心思想與技術(shù)(第2版)