The function print_reverse takes one parameter, L, which is a list. Β The function then prints the items in the list in reverse order, one item per line, WITHOUT changing the value of L.
The function count_contains_ogtakes a list of strings and returns how many strings in the list contain βogβ / βOGβ / βoGβ / βOgβ (check for βogβ, ignoring case).
Hint: Use the sequence membership operator in to help you check for βogβ in the individual strings. Create a lower-cased version of the string (lower), then use the in operator.
Define the function first_negative(nums) takes one parameter. nums, a possibly empty list of numbers. The function then returns the first negative item in numlist.
Define the function square_nums which takes a list of numbers, numlist, and returns a NEW list containing the squares of the numbers in the original list.Β The given list, numlist, should not be changed.
Define the function make_uppercase(mylist), which takes a list parameter mylist (a list of strings), mutates the list by uppercasing each string in mylist. The function returns None.
- Use the accumulate-a-list pattern, with acc_list initialized to the empty list, [] - Use a for loop to iterate i over range(100) - When STOP is read from input, break from the for loop; otherwise, append the new word to acc_list before reading the next inputΒ - Return acc_list
The function final_substrings takes a string parameter inString and returns a list of all the non-empty final substrings of inString (in order by their lengths).
The function accumulates a new list by appending alternating items from L1 and L2 until one list has been exhausted.Β The remaining items from the other list are then appended to the end of the new list, and the new list is returned.
For example, if L1 = ["hop", "skip", "jump", "rest"] and L2 = ["up", "down"], then the function would return the list: ["hop", "up", "skip", "down", "jump", "rest"].
Use a for loopto iterate k over range(min_length) to do the first part of this functionβs work. On each iteration, append to newlist the item from index k in L1, and then append the item from index k in L2 (two appends on each iteration).
AFTER the loop finishes, append the remaining items (if any) to newlist; use a decision statement to determine which list has remaining items -- then it just takes one line of code to append those items to newlist (using a slice of L1 or L2)