473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Grabbing the string 'hello' from a dictionary

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

✓ answered by Rabbit

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.

3 3062
Rabbit
12,516 Expert Mod 8TB
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
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 Expert Mod 8TB
No problem, good luck
Jun 20 '18 #4

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

Similar topics

1
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...
1
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 :...
2
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...
1
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...
3
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 :...
3
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...
4
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...
6
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...
1
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)...
9
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.