473,586 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Grabbing the string 'hello' from a dictionary

4 New Member
Expand|Select|Wrap|Line Numbers
  1.    d = {'k1':[{'nest_key':['this is deep',['hello']]}]}   
how would you grab the string 'hello' from this dictionary and why? Thanks!
Jun 19 '18 #1
3 3096
Rabbit
12,516 Recognized Expert Moderator MVP
The way I would approach it is to start reference the outer most layer and then dig inwards until you reach the value you're looking for.

This is obviously some sort of homework or exercise question, so giving you the answer out right won't help you learn anything.

Work through it. Get the first item and print it out. Then go another layer deeper and print that out. Keep adding layers till you get to the item you're looking for.
Jun 19 '18 #2
mcdermottbobby
4 New Member
It took me a while but I did figure it out, printing it out in pieces made it a lot easier, thanks for the advice!
Jun 20 '18 #3
Rabbit
12,516 Recognized Expert Moderator MVP
No problem, good luck
Jun 20 '18 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3008
by: Maxime Biais | last post by:
Hello, I heard that is possible to replace %(word) in a string with a dictionary containing { "word" : "replaced word" } with a function or a builtin from the python library. For example with the string: "hello, %(word1) %(word2) !" and the dictionary: {"word1" : "python", "word2" : "lovers"} the final string would be: "hello python...
1
1522
by: ketulp_baroda | last post by:
Hi, suppose i have dictinary as below : a={'jack':'monica','mark':'alice','jeff':'jeni'} i am storing this dictionary into the database where it is converted to string of the form : '{'jack':'monica','mark':'alice','jeff':'jeni'}' now i want to convert this string into dictionary.
2
1736
by: David Pratt | last post by:
I have string text with language text records that looks like this: 'en' | 'the brown cow' | 'fr' | 'la vache brun' Two or more language records can exist in each string (example above shows 2 - but could contain more) The second vertical line character in the example above is the record break in the pattern (between 'cow' and 'fr') ...
1
9243
by: john wright | last post by:
I have a dictionary oject I created and I want to bind a listbox to it. I am including the code for the dictionary object. Here is the error I am getting: "System.Exception: Complex DataBinding accepts as a data source either an IList or an IListSource at System.Windows.Forms.ListControl.set_DataSource(Object value)
3
11766
by: fstorck | last post by:
Hi, I'm kind of stuck with an serializing / deserializing problem using a generic dictionary holding references to various generic types. It goes as follows: <code> class MyBase : IXmlSerializable {
3
2205
by: JamesB | last post by:
I have a config screen in my app that updates a dictionary<key,value>. I want to store a copy of this before going into the config screen so if the user wants to cancel all their changes I can simply set the working copies to be the backup. So, in my code, before the config screen is shown, I do this: Dictionary<string, myClassTempDic =...
4
4859
by: Mark S. | last post by:
Hello, I have a series of changing string IDs that are loaded dynamically a couple times a minute. I need to associate each ID with a different static class so later on in the app's lifecycle it knows which static class to use for processing. I've tried: static class MyStaticObject {
6
3005
by: dudeja.rajat | last post by:
Hi, How to check if something is a list or a dictionary or just a string? Eg: for item in self.__libVerDict.itervalues(): self.cbAnalysisLibVersion(END, item) where __libVerDict is a dictionary that holds values as strings or
1
2270
by: sachin2 | last post by:
I am using 3 types of dictionaries. 1) Dictionary<string, string > d = new Dictionary<string, string>(); 2) Dictionary<string, List<string>> d = new Dictionary<string, List<string>>(); 3) Dictionary<string, Dictionary<string, string>> d = new Dictionary<string, Dictionary<string, string>>(); Now I am using GetDictionaryType Function...
9
6670
by: whosaidwhat | last post by:
Hello, I am creating a program that has a byte used as the key for a Dictionary class. The problem is best described with an example: (C# example of problem) private Dictionary<byte, string> dictionary; public void Method1() { // Set up the dictionary dictionary = new Dictionary<byte,...
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.