Bottom Page

Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Dictionary Help
#1
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
Quote
#2
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

sajley likes this post
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#3
(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]:
Quote
#4
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))
wavic and sajley like this post
Quote
#5
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
sajley likes this post
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#6
thanks to all, Worked. :)))))
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Parsing json - dictionary with in dictionary krish216 6 297 Jul-30-2019, 10:01 PM
Last Post: cvsae
  Convert List of Dictionary to dictionary of dictionary list in python kk230689 2 289 Apr-27-2019, 03:13 AM
Last Post: perfringo
  Empty attribute class dictionary after saving it in a class object dictionary 3dimensions 6 1,246 May-20-2018, 01:57 PM
Last Post: 3dimensions
  Changing values in a dictionary within a dictionary swannhouse 2 757 Apr-25-2018, 11:59 PM
Last Post: swannhouse
  Need to refer to Value of a key of a dictionary nested within a dictionary xepicxmonkeyx 14 4,284 Oct-06-2016, 07:35 PM
Last Post: wavic

Forum Jump:


Users browsing this thread: 1 Guest(s)