forked from kal179/Beginners_Python_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap_example.py
More file actions
13 lines (9 loc) · 446 Bytes
/
map_example.py
File metadata and controls
13 lines (9 loc) · 446 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
# Contribution by https://github.com/tyadav4268
#This is to demonstrate the use of map function in python
#Problem Statement: Using the function Map, count the number of words that start with ‘S’ in input_list.
#Sample Input: ['Santa Cruz','Santa fe','Mumbai','Delhi']
#Sample Output: 2
#Solution:
input_list = ['Santa Cruz','Santa fe','Mumbai','Delhi']
count = sum(map(lambda x: x[0] == 'S', input_list))
print(count) # Output: 2