Word with x or y X42828


Statement
 

pdf   zip

html

Write a function with_x_y(ls) that receives a list of arbitrary strings and returns the first character of the first string in the list that has either the lowercase letter ’x’ or the lowercase letter ’y’ in it; if no such word occurs in the list, it returns the empty string.

Sample session
>>> with_x_y( ['You', 'flagged', 'a', 'taxi', 'ride', 'Let', 'down', 'your', 'expectations', 'Of', 'a', 'different', 'night'] ) == 't'
True
>>> with_x_y( ['Noble', 'gases:', 'helium,', 'neon,', 'argon,', 'krypton,', 'xenon,', 'radon,', 'oganesson'] ) == 'k'
True
>>> len(with_x_y( ['The', 'letters', 'we', 'search', 'for', 'are', 'not', 'around', 'in', 'this', 'case'] ))
0
>>> with_x_y( ['The', 'Girl', 'with', 'the', 'Flaxen', 'Hair', 'by', 'Debussy'] ) == 'F'
True
Information
Author
José Luis Balcázar
Language
English
Official solutions
Python
User solutions
Python