Extra HW Problems¶
Add one line of code to assign a list containing only the third through fifth elements of
whoa_list
(as humans count, so [4, 6.0, 7.5]
) to the variable some_of_list
. You must use slicing and refer to whoa_list
in your code. HINT: Remember the rules of slicing and indices of sequences in Python! Also remember that the type of some_of_list
should be a list when you are done running your code!
Write code, using the accumulation pattern, to iterate over
new_string
and accumulate a new string in the variable exclam_string
with an exclamation point (!
) after each of the characters. It should look like this: h!i! !e!v!e!r!y!o!n!e!
. You must use the accumulation pattern – do not hard-code.
Define a function called
build_acronym
that accepts a string and returns an all-uppercase acronym from the string. For example, if the input were probably your term has One newcomer
, the return value should be the string PYTHON
. It should not matter how many spaces are between the words – no spaces should occur in the acronym return value.
Define a function until_three
that accepts a list. The function should return a list that is exactly the same as the input list except that if there is an integer 3 in the list, the returned list should not include that or anything that occurs in the input list after it.
For example, if the input list is ["hello", 3.5, 6.7, "python is great"]
, then the return value should also be ["hello", 3.5, 6.7, "python is great"]
. However, if the list is ["hello", 3, 6.7, "python is great"]
the return value should simply be ["hello"]
. If the input list is [3]
, the return value should be the empty list: []
.
You may choose any way of achieving this goal as long as the function until_three
you define does what is described and passes all the tests.