Download our e-book of Introduction To Python
Sulochana Kamshetty
2 years ago
my_games= [‘hockey’,’base ball’,’cricket’,’relayrace’]
uppered_games = []
for games in my_games:
games_ = games.upper()
uppered_games.append(games_)
output:- ['HOCKEY', 'BASE BALL', 'CRICKET', 'RELAYRACE']
def starts_with_A(s):
return s[0] == "A"
fruit = ["Apple",
"Banana", "Pear", "Apricot", "Orange"]
map_object =
map(starts_with_A, fruit)
print(list(map_object))
My_List = list(range(50))print([i for i in lst],end=",")
def is_odd(num):
return num%2!=0
# To use it with a list for filter, we will pass it as an argument in the
filter function.
filter_lst = filter(is_odd,lst)
print(type(filter_lst))
from functools import reduce
def
do_sum(x1, x2):
return x1 + x2
reduce(do_sum,
[1, 2, 3,4])
10