j,k = { 'w' : 'work' , 'k' : ' kite'} | Sololearn: Learn to code for FREE!


j,k = { 'w' : 'work' , 'k' : ' kite'}

Please tell what type of object it is, and how can access its values


5/17/2022 3:50:38 PM

Subhash Devda

14 Answers

New Answer


Nuhu Abdul Bashit , please do not post a new question / thread inside an exising thread of a other user.


Subhash Devda , by using the code: j,k = { 'w' : 'work' , 'k' : ' kite'} we will store the key 'w' in variable 'j', and key 'k' in variable 'k' if we wanted to get the values stored in the variables instead of the keys, we need this code: j,k = { 'w' : 'work' , 'k' : ' kite'}.values() we will store the value 'work' in variable 'j', and the value 'kite' in variable 'k'


Please tag the relevant programming language. What is "it"? The variables j and k? The term right side of the =?


Maybe in your programming language ".." is not a dictionary, but in Python you did the unpacking of the keys πŸ˜‰ j,k = { 'w' : 'work' , 'k' : ' kite'} dic = { 'w' : 'work' , 'k' : ' kite'} print(dic[j]) print(dic['k'])


This process in some languages is called destructuration. Ex in js: [x , y] = {x : "some" , y : "other"} // x = "some" , y = "other" The object can be called map(java) , dictionary(py) , object(js)


when i used optparse moudule parser = optparse.OptionParser() parser.add_option('-i', '--interface', dest='interface', help='Add mac address') parser.add_option('-m', '--mac', dest='new_mac') (option, arguments) = parser.parse_args() when print option it return dictinory object as i asked


i know to access the values by parser module. but, im just trying to access values like dictinory, but i'ts not possible


Hello. This is a little vague. What language is this and are you asking about what kinda data structure it is? It looks like it a map/dictionary based on the key-value pairs. A I can't answer your second question because you did not state the language.


this code not showing error in python. when we print(j ,k) output >> w k. but can't access values


This is dictionary. k['w'] and k['k']


Solo , sorry to say that it's not as dictionary


Of course {'w': 'work', 'k': 'kite'} is a dictionary. Dictionary entries are key-value pairs: dict['key': 'value']


Just to add on to Lisa comment, it might also be called a Map depending on the language.... Which you still haven't told us yet so it's hard to help.


Write a program using nested loops to display the following sample out. Allow the user to enter a number and use the number to generate the output. In this the user entered 7 1 135 1357 135 1