Ordered lists in Python are lists or tuples where lists are mutable and tuples are not. Lists and tuples may be accessed by index or by slices.
- The basic sequential types in Python are lists and tuples.…Lists are mutable and tuples are not.…Here in Komodo, I've opened a working copy of list.py…from chapter eight of the exercise files.…And here we define a list,…to notice that the square brackets…are used to create the list.…A list is an ordered collection, it's sequential…and it's interval.…And you'll notice down here in our print list function,…we're iterating with the foreloop.…
So when I run this, it lists in order,…each of the elements in the list,…rock, paper, scissors, lizard, Spock.…I can access an individual item in the list…using an index.…So I can say print game sub one, like this.…And if I run that, you'll see we get paper.…Lists are zero-based so item number zero would be rock,…item number one would be paper.…
So the first number is the beginning of the slice…and the second number is the end of the slice noninclusive.…So in other words, this would be items number one and two.…So this would be paper and scissors.…And if I run this, see we get paper and scissors.…
- Python anatomy
- Types and values
- Conditionals and operators
- Building loops
- Defining functions
- Python data structures: lists, tuples, sets, and more
- Creating classes
- Handling exceptions
- Working with strings
- File input/output (I/O)
- Creating modules
- Integrating a database with Python db-api
Skill Level Intermediate
Python: Programming Efficientlywith Michele Vallisneri2h 15m Intermediate
2. Language Overview
3. Types and Values
8. Structured Data
11. String Objects
12. File I/O
13. Built-in Functions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.