World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Download our e-book of Introduction To Python
4.5 (1,292 Ratings)
559 Learners
Sulochana Kamshetty
a year 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