Write a function extract_middle_elements(lst:list) that takes a list of integers and returns a new list containing only the middle element if the list has an odd length, or the two middle elements if the list has an even length.
NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition.
extract_middle_elements([7, 8, 9, 10, 11, 12, 13]) -> [10]
Explanation: The list has an odd length (7), so the middle element is 10.
extract_middle_elements([3, 6, 9, 12, 15, 18]) -> [9, 12]
Explanation: The list has an even length (6), so the two middle elements are 9 and 12.
Implement this function:
def extract_middle_elements(lst:list):
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: lst.
Input
[7, 8, 9, 10, 11, 12, 13]
Output
[10]
Write a function extract_middle_elements(lst:list) that takes a list of integers and returns a new list containing only the middle element if the list has an odd length, or the two middle elements if the list has an even length. NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition. ### Examples extract_middle_elements([7, 8, 9, 10, 11, 12, 13]) -> [10]\ Explanation: The list has an odd length (7), so the middle element is 10.\ extract_middle_elements([3, 6, 9, 12, 15, 18]) -> [9, 12]\ Explanation: The list has an even length (6), so the two middle elements are 9 and 12. ## Your task Implement this function: ```python def extract_middle_elements(lst:list): ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `lst`. ## Example **Input** ``` [7, 8, 9, 10, 11, 12, 13] ``` **Output** ``` [10] ``` Write a function get_first_last_chars_sorted(t) that takes a tuple of strings (with at least two strings) as input and returns a new string formed by: taking the first character of the first string, and\ the last character of the last string, Then, return these two characters arranged in alphabetical order.\ (Assume all strings are in lowercase.) Hint: Alphebetical order can be determined by comparing two chars using comparision operators. NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition. ### Examples get_first_last_chars_sorted(("apple", "banana", "cherry")) -> "ay" First char of "apple" -> 'a', last char of "cherry" -> 'y'\ Sorted alphabetically -> "ay"\ get_first_last_chars_sorted(("moon", "sun")) -> "mn"\ First char of "moon" -> 'm', last char of "sun" -> 'n'\ Sorted alphabetically -> "mn"\ get_first_last_chars_sorted(("land", "cab")) -> "bl"\ First char of "land" -> 'l', last char of "cab" -> 'b'\ Sorted alphabetically -> "bl" ## Your task Implement this function: ```python def get_first_last_chars_sorted(t: tuple) -> str: ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `t`. ## Example **Input** ``` ("apple", "banana", "cherry") ``` **Output** ``` 'ay' ``` Given two strings, bread and filling, split bread into two equal halves and insert the filling in between them to form a new word.\ Assume the string bread will be of even length. NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition. ### Example ``` >>> bread = "topbun" >>> filling = "butter" >>> word_sandwich(bread,filling) 'topbutterbun' ``` ## Your task Implement this function: ```python def word_sandwich(bread, filling): ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `bread`, `filling`. ## Example **Input** ``` "topbun" "butter" ``` **Output** ``` 'topbutterbun' ```