Lists are the most versatile type in Python, lists can be used to store data or to implement other more complex data structures, take a look at the implementation of queues at: Python circular queues Priority queues with agin Python 3 Round Robin Priority queues A list can be created by inserting comma-separated values inside square brakets:LIST_A = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]The empty list is []. One of the most interesting point about python lists is that the elements of a list need not to be of the same type:LIST_B = [0, "word", "another word", 3.01, 4, 5, 6, 7, 8, 9]LIST_B is a valid list in python. The content of lists can be printed using the print function:print(LIST_A) print(LIST_B)and its output is [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [0, 'word', 'another word', 3.01, 4, 5, 6, 7, 8, 9] To access the elements in a list python uses the square brackets.print(LIST_A[2:5]) print(LIST_B[1])And its output is:2 wordPython lists provide also the slicingprint(LIST_A[2:5]) [2, 3, 4]To add an element to the end of a list you can use the append methodLIST_A.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
python,Tower of Babel,lists
python,Tower of Babel,lists
No comments:
Post a Comment