Question: Please solve in Python Write a function that takes two lists: a list of states (as strings) and a list of corresponding nicknames (also as
Please solve in Python
Write a function that takes two lists: a list of states (as strings) and a list of corresponding nicknames (also as strings). Your function should return a list of tuples, where each tuple contains the state as its first element, and the corresponding nickname as its second element, in the same order as the inputs. Return an empty list if no nicknames are provided.
Note:
You can assume that the states list is at most as long as the nicknames list.
If there are not enough states to make a tuple you should use 'NO STATE PROVIDED' as a placeholder of the state value. (See the doctests for more examples.)
""" >>> combine(['NV', 'CA', 'HI'], ['Silver State', 'Golden State', 'Aloha State']) [('NV', 'Silver State'), ('CA', 'Golden State'), ('HI', 'Aloha State')]
>>> combine(['NV', 'CA'], ['Silver State', 'Golden State', 'Aloha State']) [('NV', 'Silver State'), ('CA', 'Golden State'), ('NO STATE PROVIDED', 'Aloha State')]
>>> combine([], ['Golden State', 'Aloha State']) [('NO STATE PROVIDED', 'Golden State'), ('NO STATE PROVIDED', 'Aloha State')] """
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
