Updated Week 09
Updated Week 09
0 55 -5
1 65 -4
2 75 -3
3 85 -2
4 95 -1
my_list= [1,2,3,4,5]
print(list[2]) #Positive indexing Output
print(list[-2]) #Negative indexing 3
4
my_list = [55,65,75,85,95]
my_list[1] = 56
print(my_list)
Output:
[55,56,75,85,95]
my_list=[1,2,3]
your_list=[4,5,6]
our_list=my_list+your_list
print(our_list) Output:
[1, 2, 3, 4, 5, 6]
our_list = [1,2,3,4,5,6]
print(our_list * 2)
Output:
[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6,]
all() Adds True if all items are true (list, tuples, dictionaries)
my_tuple = (1,2,3,4,5)
print(my_tuple[1:3])
output:
2,3
Len((1,2,3)) 3 Length
Sample list=[‘yellow”,”Pink”,”Red”,”Green”,”Blue”,”Purple”]
Output =[‘”Pink”,”Red”,”Green”]
Sample list=(”yellow”,”Pink”,”Red”,”Green”,”Blue”,”Purple”)
Output =(”Pink”,”Red”,”Green”)