- Introduction to Python
- Python: Choosing a Text Editor or IDE
- Python: Hello World
- Python: Variables, Strings and Numbers
- Python: Variable Naming
- Python: Math, Familiar
- Python: Math, Less Familiar
- Python: Mathematical Order of Operations
- Python: Introducing PEP 8
- Python: Text Concatenation
- Python: if Statements and Comparison Operators
- Python: else and elif statements
- Python: Testing Multiple Conditions
- Python: Testing Sets of Conditions
- Python: Nested if Statements
- Python: Lists
- Python: Adding To and Changing Lists
- Python: Lists: Take a Slice, Delete Elements, Popping Elements
- Python: Tuples
- Python: for Loops
- Python: Nested for Loops
- Python: Capturing and Formatting User Input
- Python: Dictionaries
- Python: Functions
- Python: While Loops
- Python: Data Files
- Python: Using Pexpect
- Python : Using Pexpect : ftpTestOffload.sh
- Python : Using Pexpect: ftpTest.py
- Python: DCL Conversion to Python
Go to Chapter 17 of A Smarter Way.
Return to our lists page:
…and scroll down slightly because the page TOC is (again) broken.
Taking a slice from a list:
friends = ['bill', 'jeff', 'jim', 'scott', 'joel'] # Grab the first three users in the list. first_three = friends[0:3] for friend in first_three: print(friend.title())
Now go to Chapter 18 of A Smarter Way.
Remove an item by position:
Remove an item by value:
Now go to Chapter 19 of A Smarter Way.
Popping an element:
This is a unique operation. Popping an item removes the top item from a list, and passes it to a variable or other operation:
first_friend = friends.pop(0)
See http://introtopython.org/lists_tuples.html#Want-to-see-what-functions-are? … and scroll down slightly.
- Continue editing examples.py.
- Slice a range of items from your list.
- Delete one item by index.
- Delete one item by value.
- Pop a value from the list, put it into a
- Perform a test to see if an item is in your list.