diff --git a/map_example.py b/map_example.py new file mode 100644 index 0000000..e3029f3 --- /dev/null +++ b/map_example.py @@ -0,0 +1,11 @@ +#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