# File: ChapterLists/mapList.py """ [2, 4, 18] enter numbers till 0 > 4 > 5 > 1 > 0 sorted input list= [1, 4, 5] ASCII in Alan: [65, 108, 97, 110] [3, 1, 4] [3, 1, 4] [2] """ def removeNegative(x): return x >= 0 def doubleUp(x): # double up a number return x*2 def myinc(x): return x+1 def incAll(V): return list(map(myinc,V)) def inputPos(): x = 1 L = [] print('enter numbers till 0') while x != 0: x = int(input("> ")) if ( x != 0 ): L.append( x ) L.sort() print("sorted input list=",L) def main(): print(list(map(doubleUp,[1,2,9]))) # [2,4,18] inputPos() #call function print("ASCII in Alan:", list(map(ord,'Alan'))) #65 108 97 110 print(list(map(myinc,[2,0,3]))) print([x + 1 for x in [2,0,3]]) # [3,1,4] print([x for x in [2,0,-3] if x > 0]) #[2] #filter L = list(map( doubleUp, filter(removeNegative, [3,-2,1]) )) #[6,2] print(L) main()