def holiday(type, lang):
hols = {"Christian": "Christmas, Noël, Weichnachtszeit",
"Jewish": "Channukah, Hannukah, Chanukkah",
"Muslim": "Ramadan, Ramadan, Ramadan"}
sals = {"Christian": "Happy, Joyeux, Fröhliche",
"Jewish": "Happy, Joyeux, Happy",
"Muslim": "Happy, Joyeux, Schön"}
hol_choice = string.split(hols[type], ",")
sal_choice = string.split(sals[type], ",")
holiday = string.strip(hol_choice[lang])
salutation = string.strip(sal_choice[lang])
return(holiday, salutation)
The second function takes two arguments: the
type of
holiday and the
language in which the output is to be
phrased. In the course of the function, two associative arrays
are defined (associative arrays are called dictionaries in
Python). Depending on the key supplied by
type, a trio
of equivalents is split via string.split and assigned in turn to
hol_choice and
sal_choice. Which of the trio is
returned is determined by the value of
lang. This value
is stripped of any beginning and end spaces by string.strip and
assigned as needed to
holiday or
salutation.
These two string variables then form the tuple that is returned
by the function.