[Tutor] [SOLVED] Append sub-key to dictionary
M. Bashir Al-Noimi
mbnoimi at gmx.com
Tue May 25 20:56:58 CEST 2010
Thanks Vince ;-)
On 25/05/2010 07:38 م, vince spicer wrote:
> On Tue, May 25, 2010 at 12:28 PM, M. Bashir Al-Noimi <mbnoimi at gmx.com
> <mailto:mbnoimi at gmx.com>> wrote:
>
> Hi All,
>
> I'm trying to append a new sub-key to specific dictionary but it
> replacing the content of parent key instead of add a sub-key!
>
>
> How I can fix this issue?
>
> --snippet--
>
> addressbook = {
> 'work': {
> 'Andre': {
> 'phone': '22761654',
> 'e-mail': '5456646',
> 'address': 'Syria, Aleppo',
> 'website': 'www.sdff.com <http://www.sdff.com>'
> }
> },
> 'Friends': {
> 'Ahmad': {
> 'phone': '34646464',
> 'picture': '/home/fiends/wael.png',
> 'posts': {
> 'blog': 'http://www.dsfd.com/ <http://www.dsfd.com/>',
> 'newspaper': 'http://news.com/ <http://news.com/>'
> }
> },
> 'Issa': {
> 'e-mail': 'asd at dsfdsc.com <mailto:asd at dsfdsc.com>'
> }
> }
> }
>
> addressbook['Friends'] = {
> 'kassem': {
> 'address':'Aleppo Street',
> 'Country':'Palestine',
> 'articles':{
> 'blog':'http://blogger.com <http://blogger.com>',
> 'news':'http://news.com/ <http://news.com/>'
> }
> }
> }
>
>
> --
> Best Regards
> Muhammad Bashir Al-Noimi
> My Blog:http://mbnoimi.net
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org <mailto:Tutor at python.org>
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
> You may have better results with:
>
> addressbook['Friends']['kassem"] = {
> 'address':'Aleppo Street',
> 'Country':'Palestine',
> 'articles':{
>
> 'blog':'http://blogger.com',
>
> 'news':'http://news.com/'
> }
> }
> }
>
>
> this will create a new key in the Friends dict
>
> Vince
--
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100525/47b97d24/attachment-0001.html>
More information about the Tutor
mailing list