Day 4:Python Newbie?

prices=["Apple",90,"Mango",70,"Banana",45]
prices=[["Apple",90],
["Mango",70],
["Banana",45]]
prices=["Apple",90,"Mango",70,"Banana",45]
prices[0] #output="Apple"
prices[3] #output=70
price[-1] #output=45
price[-3] #output=70
prices[1:3] #[90,"Mango"]
prices[2:5] #["Mango",70,"Banana"]
prices[:3] #["Apple",90,"Mango",70,"Banana",45]
prices[4:] #["Banana",45]
prices=[["Apple",90],
["Mango",70],
["Banana",45]]
prices[1][0] #output="Mango"
prices[2][1] #output=45

List Manipulation:

final_prices =prices+[["strawberry",110]]
del(final_prices[3])
final_prices[1][1] = 120

--

--

--

Data Scientist who loves to teach machine through data.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adnan Khan

Adnan Khan

Data Scientist who loves to teach machine through data.

More from Medium

Stop Watching Programming Tutorials This Way

How to Learn a New Programming Language Fast — Seventh Heaven

C vs C++: The Important Points Of Difference You Must Know

Which programming language should I learn first if I could start over?