Python is known to b easy, useful and fun to use. And it is.
Lists are what in other languages they call array.
To add something to a list:
There's another way, too:
Lists are mutable objects
If you want to isert an item from a list you can
>>> names.insert(1,"Carl")
>>> names
In the next post we will see how to delete an item from a list
Lists are what in other languages they call array.
Let's make a list of names
>>> names = ["John","Mary","Sean"]
To add something to a list:
>>> names.append("Sally")
>>> names
["John","Mary","Sean","Sally"]
There's another way, too:
>>> names += ["Jim"]
>>> names
["John","Mary","Sean","Sally"]
Lists are mutable objects
If you want to isert an item from a list you can
>>> names.insert(1,"Carl")
>>> names
In the next post we will see how to delete an item from a list
Comments
Post a Comment