In: Computer Science
Question 12 PYTHON:
Write a function named first_last that takes a single parameter,
string_list (a list of strings). The
function first_last should return a list of the strings in
string_list that are not empty and that begin
and end with the same letter.
For example, the following would be correct input and output for the function first_last.
response = ['to', 'that', 'I', 'say', '', 'hurrah']
print(first_last(response))
['that', 'I', 'hurrah']
Question 13 (20 points)
Write a function named number_luck. The function number_luck takes two parameters:
1. lucky, a list of lucky numbers between 2 and 12,
inclusive
2. unlucky, a list of unlucky numbers between 2 and 12,
inclusive
Every number is either lucky, unlucky or boring (neither lucky nor unlucky).
The function number_luck should
1. ask the user for a number in the range 2 to 12 (you may
assume that the user provides valid
input)
2. print a message echoing the user’s number and stating whether it
is lucky, unlucky or boring
3. return an integer that is the user’s number
For example, the following would be correct input and output.
>>> a_num = number_luck([7, 11], [2, 3, 12])
Give me a number from 2 to 12: 7
7 is lucky. You win!
>>> print(a_num)
7
Python code:
def first_last(string_list):
l=[]
for i in string_list:
if len(i)==0 or
i[0]!=i[-1]:
pass
elif(i[0]==i[-1]):
l.append(i)
else:
pass
return l
def number_luck(lucky,unlucky):
n=int(input("Give me a number in the range of 2
to 12 inclusive : "))
if n in lucky :
return "lucky"
elif n in unlucky:
return "unlucky"
else:
return "neither lucky
nor unlucky"
print("Question12")
response = ['to', 'that', 'I', 'say', '', 'hurrah']
print("Initial list : ",response)
print("After callng first_last function :
",first_last(response))
print()
print("Question13")
a_num = number_luck([7, 11], [2, 3, 12])
print(a_num)
Execution screenshots:

Note:please like the
answer if you are satisfied with it. Thank you in advance.