Skip to content

011 lists.md #4

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion 011-Lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,19 @@

## What are lists in Python?

A list is a collection of data and can be applied to a vairable. Lists can comprise of integers, floats and strings. The elements of a list are indexed and have a specific order, meaning you can access specific items within a list using its index number (which always starts at 0 for the first item).
A list is a collection of data and can be applied to a variable. Lists can comprise of integers, floats and strings. The elements of a list are indexed and have a specific order, meaning you can access specific items within a list using its index number (which always starts at 0 for the first item).
You can also print a particular variable from a particular list
An example is illustrated below
Fruits=[Orange,mango,guava,pineapple,apple,waterlemon,banana]
To print a fruit from the list(fruits),we use the print statement+fruits+index of the fruit[-]
Note that index of any list starts from 0.

#Printing from lists
If we have a list and we want to print from that particular list,we use the print statement+name of the list+index of the value in the list tho index starts from zero(0)
E.g
Animals=[dog,goat,horse,lion,elephant,hen,donkey]
To print lion from list(Animals),
We use-print Animals[3]
To print dog,
We use-print Animals[0]