Extra ExercisesΒΆ

  1. Assign the value of the 34st element of lst to the variable output.

1.1 Assign the value of the 23rd element of lst to the variable checking.

  1. Assign the number of elements in lst to the variable output.

2.1 Assign the number of elements in lst to the variable num_lst.

  1. Assign the value of the last element of lst to the variable the variable output. 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.

  1. Create a new list of the 6th through 13th elements of lst (eight items in all) and assign it to the variable output.

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``.

  1. Create a new string from str1 that is all lower case, and assign it to the variable output. Do not hard code this: use a python string method to convert str1 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.

  1. Create a variable output and assign it to a list whose elements are the words in the string str1.

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.

  1. 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.

  1. Get rid of all values of 7 from the list, numbers.

8.1 Please get rid of the e’s from this list.

Next Section - Introduction: Iteration