Open up the console. Type the following example code using interactive mode:
a_list = [123 , 'First Item' , 456 , 'Second Item' ]
b_list = a_list [0 :2 ]
print (a_list )
print (b_list )
In your notebook, respond to the following:
What happens to a_list
?
What is in b_list
?
a_list = [123 , 'First Item' , 456 , 'Second Item' ]
a_list .remove ('First Item' )
print (a_list )
Continue in your notebook. Respond to the following questions:
What does remove
do?
What is the length of a_list after the remove?
a_list = [123 , 'First Item' , 456 , 'Second Item' ]
popped_value = a_list .pop ()
print (a_list )
print (popped_value )
Continue your responses in your notebook:
what does pop
do?
What is the difference between remove
and pop
?
a_list = [123 , 'First Item' , 456 , 'Second Item' ]
b_list = a_list + ['Third Item' ]
print (a_list )
print (b_list )
Continue your responses to the following in your notebook:
What happens to a_list?
What is in b_list?
a_list = ['First Item' ]
print (a_list )
a_list .append ('Second Item' )
print (a_list )
In your notebook, answer:
What does append
do?
What would be the length after append
?