1/5
## Arrays / Lists We can assign values to variables in Python, like so: ```python my_variable = 7 print(my_variable) ``` We can assign many different types of values to variables: ```python my_number = 10 my_boolean = True my_string = 'hello!' ``` We can even type hint our variables: ```python my_typed_number: int = 9 my_typed_bool: bool = False my_typed_string: str = "hi!" ``` We can also update variables: ```python my_variable = 77 ``` ### Lists We can store collections of values in a list, or an array: ```python my_list: list = [7, "cat", True] print(my_list) ``` We can see that each item in the list has an index. It's important to remember that in Python, the first index is `0`. ```python # [7, "cat", True] # [0, 1, 2] ``` We can use square bracket notation to update a specific item in the list: ```python my_list[1] = "dog" print(my_list) ``` Python provides a convenient way to sort lists of numbers: ```python my_numbered_list = [0, 7, 8, 2, 3, 99] print(my_numbered_list) my_numbered_list.sort() print(my_numbered_list) ``` We can use the `.sort()` method to sort our list.
A practical introduction to Python lists. This lesson covers creating lists, understanding indexes, updating elements, and using the sort method to organize lists.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Python basics
Introduction to Web3.py
Introduction to Titanoboa
Introduction to Moccasin
How to create an ERC-20
How to test Python code and Vyper smart contract
How to deploy Vyper smart contracts on ZKsync using Moccasin
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on January 14, 2025
Duration: 2h 20min
Duration: 1h 51min
Duration: 58min
Duration: 2h 23min
Duration: 53min
Duration: 2h 24min
Duration: 28min
Duration: 1h 54min
Duration: 11min
Course Overview
About the course
Python basics
Introduction to Web3.py
Introduction to Titanoboa
Introduction to Moccasin
How to create an ERC-20
How to test Python code and Vyper smart contract
How to deploy Vyper smart contracts on ZKsync using Moccasin
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on January 14, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar