First names X18857


Statement
 

pdf   zip

html

Dessign the function primers_noms(f, n) that returns a list of male nouns. Function parameters are a list of strings f and a non negative integer n. The result list must contain the first n male nouns in f. If there are less than n male nouns the function must return a list with those male nouns and at the end the string ’i cap mes’.

def es_nom_de_noi(s):
    return s in ['Albert', 'Antoni', 'Lluis', 'Marc', 
                 'Pere', 'Pol', 'Ramon']
Sample session
>>> primers_noms(['Ramon', 'Laia', 'Gina', 'Alba', 'Aina', 'Lluis'], 2)
['Ramon', 'Lluis']
>>> primers_noms(['Ramon', 'Laia', 'Gina', 'Alba', 'Aina', 'Lluis'], 3)
['Ramon', 'Lluis', 'i cap mes']
>>> primers_noms(['Laia', 'Gina', 'Alba', 'Aina'], 2)
['i cap mes']
>>> primers_noms(['Pere'], 0)
[]
>>> primers_noms([], 5)
['i cap mes']
Information
Author
InfBesos
Language
English
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python