Posts: 30
Threads: 9
Joined: Dec 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!
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.
Posts: 2,955
Threads: 48
Joined: Sep 2016
Dec-20-2016, 07:43 PM
(This post was last modified: Dec-20-2016, 07:44 PM by wavic.)
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
Posts: 30
Threads: 9
Joined: Dec 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 ???
in[1] , out[2]
in[1]:
in[2]:
out[2]:
Posts: 11,859
Threads: 472
Joined: Sep 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))
Posts: 2,955
Threads: 48
Joined: Sep 2016
Dec-20-2016, 07:53 PM
(This post was last modified: Dec-20-2016, 07:54 PM by wavic.)
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
Posts: 30
Threads: 9
Joined: Dec 2016
thanks to all, Worked. :)))))
|