Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14360

Whats the problem with the map function? Someone explain in details

$
0
0
import restates = ['    Alabama  ', 'Georgia!', 'Georgia', 'georgia', 'FlOrIda','south    carolina###', "West virginia?"]result1 = []def myFunc(x):  return re.sub('[!#?]', '', x)funcs = [str.strip, str.title, myFunc]def resultFunc(need_change, after_change):'''  need_change - list which one need to be changed  after_change - result list'''  for elements in need_change:    for func in funcs:      elements = func(elements)    after_change.append(elements)  return after_change     result3 = []a = list(map(resultFunc, states, result3)) 

why this code return None?

But this work

import re states = ['    Alabama  ', 'Georgia!', 'Georgia', 'georgia', 'FlOrIda','south    carolina###', "West virginia?"]result1 = []def myFunc(x):  return re.sub('[!#?]', '', x)funcs = [str.strip, str.title, myFunc]def resultFunc(need_change, after_change):'''  need_change - list which one need to be changed  after_change - result list'''  for elements in need_change:    for func in funcs:      elements = func(elements)    after_change.append(elements)  return after_change     result3 = []resultFunc(states, result3)

Viewing all articles
Browse latest Browse all 14360

Trending Articles