Menu
Coddy logo textTech

map

Lesson 6 of 9 in Coddy's Python Lambda Functions course.

Introducing map built-in function,

map(function, iterable)

The map() function applies a given function to each element of an iterable and returns an iterator containing the results.

Here is an example of using lambda with map function,

lst = [1, 4, 2, 9, 13, 6]
lmbd = lambda x : x * x
squares= list(map(lmbd, lst))
print(squares)  # [1, 16, 4, 81, 169, 36]
challenge icon

Challenge

Easy

You are given a code.

Assign to function a lambda function that gets one argument. If the argument is a vowel then it returns the vowel doubled, otherwise returns the argument unchanged.

Vowels are the characters - 'a', 'e', 'i', 'o', 'u'.

Try it yourself

iterable = input() # Don't change this line
function = ?

# Don't change below this line
double_vowels = map(function, iterable)
print(''.join(list(double_vowels)))

All lessons in Python Lambda Functions