Thread: [Python3] Select [1] from map() iterator
hello,
title maybe bit awkward, didn't know how describe differently.
have dictionary want take numbers "if in" construct:
i put whole construction made dictionary map() construct returns iteration in python2 (when map() still created list instead of iterator) (just show it):code:some_dict = {'2001-10-11': 12, '2001-10-12': 10.5, '2001-10-13': 11.7, '2001-10-14': 12.1, } datum = '2010-02-13' if datum in some_dict: print(some_dict[datum]) else: # else
at point don't know however, how check if date in there , if in there how second part (python2_maplist[that iteration][1]).code:python2_maplist = [('2001-10-11', 12), ('2001-10-12', 10.5), ('2001-10-13' 11.7), ('2001-10-14', 12.1)]
kind of have hard time explaining this, hope guys understand.
tips welcome!
i'm not sure if that's want, can use in on iterator:
alternatively, can construct list using list():code:firas@av104151 ~ % python3 python 3.2 (r32:88452, feb 20 2011, 11:12:31) [gcc 4.2.1 (apple inc. build 5664)] on darwin type "help", "copyright", "credits" or "license" more information. >>> t = [0, 1, 2, 3] >>> '1' in map(str, t) true >>> '4' in map(str, t) false
code:>>> list(map(str, t)) ['0', '1', '2', '3']
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [Python3] Select [1] from map() iterator
Ubuntu
Comments
Post a Comment