Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Example:
my_tuple = (10, 20, 30)
print(my_tuple[0]) # Output: 10
Why use tuples?
0.Example:
my_list = [10, 20, 30, 40]
print(my_list[0]) # Output: 10
print(my_list[2]) # Output: 30
sequence[start : stop : step]Examples:
my_list = [10, 20, 30, 40, 50, 60]
print(my_list[1:4]) # [20, 30, 40]
print(my_list[:3]) # [10, 20, 30]
print(my_list[3:]) # [40, 50, 60]
print(my_list[::2]) # [10, 30, 50]
print(my_list[::-1]) # [60, 50, 40, 30, 20, 10]
-1 (last element), -2 (second last), etc.Example:
my_list = [10, 20, 30, 40, 50]
print(my_list[-1]) # 50
print(my_list[-2]) # 40
print(my_list[-4:-1]) # [20, 30, 40]
print(my_list[-3:]) # [30, 40, 50]
print(my_list[::-1]) # [50, 40, 30, 20, 10]