python - Adding to a dictionary directly from input() -


the following snippet want do:

m = [int(x) x in input().split()] d = {} in range(26):        d[chr(i+97)] = m[i] 

can done directly while taking input using generator function or like:

((d[chr(i+97)] = k) in range(26) , k in input().split())

edit: found solution; using zip(). this:

d = {(u,v) (u,v) in zip(m,map(int,input().split()))} 

this works doesn't ordered , d[chr(97)] seems missing.

d ={chr(i+97):x i, x in enumerate(input().split())} 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -