© 2017 OctoMiao.
map is sometimes more convinient instead of for. The code
newlist = for word in oldlist: newlist.append(word.upper())
can be reformed using map
newlist = map(str.upper, oldlist)
for loop is sometimes slow because the dot evaluation inside is evaluated for each loop. Thus the following code is more efficient.
upper = str.uppernewlist = append = newlist.appendfor word in oldlist: append(upper(word))
Last updated December 04, 2015