Question: 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
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 users number and stating whether it is lucky, unlucky or boring 3. return an integer that is the users 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
