Exercises¶
- Assign the value of the 34th element of
lst
to the variableoutput
.
1.1 Assign the value of the 23rd element of lst
to the variable checking
.
- Assign the number of elements in
lst
to the variableoutput
.
2.1 Assign the number of elements in lst
to the variable num_lst
.
- Assign the value of the last element of
lst
to the variable the variableoutput
. Do this so that it doesn’t matter the length of lst.
3.1 Assign the last element of lst
to the variable end_elem
. Do this so that it works no matter how long lst is.
- Create a new list of the 6th through 13th elements of
lst
(eight items in all) and assign it to the variableoutput
.
4.1 Create a new list using the 9th through 12th elements (four items in all) of new_lst
and assign it to the variable``sub_lst``.
- Create a new string from
str1
that is all lower case, and assign it to the variableoutput
. Do not hard code this: use a python string method to convertstr1
to lower case.
5.1 Create a variable called low_stri
and assign it the value of stri, but lowercased. Do not hard code this: use a python string method to convert str1 to lower case.
- Create a variable
output
and assign it to a list whose elements are the words in the stringstr1
.
6.1 Create a variable called wrds
and assign to it a list whose elements are the words in the string sent
. Do not worry about punctuation.
- Add the pet “goldfish” to the end of the list of pets,
pets
. Do this using a list method.
7.1 Add the string “dogs” to the end of the list pets
. Do this using a list method.
- Get rid of all values of 7 from the list,
numbers
.
8.1 Please get rid of the e’s from this list.