Python Forum
Dictionary Help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Dictionary Help (/thread-1286.html)



Dictionary Help - sajley - Dec-20-2016

hi guys  

mydict = {'transform':[4,52,6.3] , 'rotation':[77,89,12] , 'scale':[44,55,96]}
mydict['scale']
Output:
[44,55,96]
how i can access the list index, for example only access 55 or 96, no all items!   Think

i learn python for CG & VFX , i need to define (for example) 'scale' [x,y,z] , how i can access to x or y or z, in dictionary.   Think


RE: Dictionary Help - wavic - Dec-20-2016

The same way you access a list items. 
In [1]: mydict = {'transform':[4,52,6.3] , 'rotation':[77,89,12] , 'scale':[44,55,96]}

In [2]: mydict['scale'][2]
Out[2]: 96



RE: Dictionary Help - sajley - Dec-20-2016

(Dec-20-2016, 07:43 PM)wavic Wrote: The same way you access a list items. 
In [1]: mydict = {'transform':[4,52,6.3] , 'rotation':[77,89,12] , 'scale':[44,55,96]}

In [2]: mydict['scale'][2]
Out[2]: 96

thankyou
what is:  in & out ???   Huh
in[1]  ,  out[2]     Think
in[1]:
in[2]:
out[2]:



RE: Dictionary Help - Larz60+ - Dec-20-2016

To get the value:
z = mydict['scale'][2]
print(z)
To see if the value is in any dict entry:
mydict = {
    'transform': [4, 52, 6.3],
    'rotation' : [77, 89, 12],
    'scale': [44, 55, 96]
}

for key, value in mydict.items():
    if 96 in value:
        print('found 96 in: {}'.format(key))



RE: Dictionary Help - wavic - Dec-20-2016

It's just a Python interpreter prompt. Like '>>>' in the usual Python interpreter. It's called IPython and it's awesome. 
See this: https://www.youtube.com/watch?v=vrdYvjGTrQA


RE: Dictionary Help - sajley - Dec-20-2016

thanks to all, Worked. :)))))