Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 8th, 2005, 6:23 AM   #1
pywacky
Newbie
 
pywacky's Avatar
 
Join Date: Mar 2005
Posts: 2
Rep Power: 0 pywacky is on a distinguished road
SOLVED Dictionary with two different languages ?

I would like to construct a dictionary that would contain two different languages.

Could someone give me an example of how this might be accomplished?

Thank You

Pywacky

Last edited by pywacky; Mar 8th, 2005 at 9:42 AM.
pywacky is offline   Reply With Quote
Old Mar 8th, 2005, 8:10 AM   #2
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
just make 2 dictionaries and run the word you're checking through both.
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Mar 8th, 2005, 9:30 AM   #3
pywacky
Newbie
 
pywacky's Avatar
 
Join Date: Mar 2005
Posts: 2
Rep Power: 0 pywacky is on a distinguished road
Solved

HOLD IT ! My poor old brain finally figured out what you meant. All is well, problem solved.

Many thanks

Last edited by pywacky; Mar 8th, 2005 at 9:42 AM.
pywacky is offline   Reply With Quote
Old Mar 8th, 2005, 11:11 AM   #4
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Smile

Quote:
Originally Posted by Dizzutch
just make 2 dictionaries and run the word you're checking through both.
If you had made an Englishutch dictionary, how could you convert that to a Dutch:English dictionary? Any ideas?
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote
Old Mar 8th, 2005, 12:45 PM   #5
block01cube
Newbie
 
Join Date: Feb 2005
Posts: 10
Rep Power: 0 block01cube is on a distinguished road
Quote:
Originally Posted by Dietrich
If you had made an Englishutch dictionary, how could you convert that to a Dutch:English dictionary? Any ideas?
If you mean how do you change a dictionary from keys:items to items:keys, try this:

def reversedict(original_dict):

    dict2 = {}

    dict_list = original_dict.items()

    for i in dict_list:
        dict2[i[1]] = i[0]
    
    return dict2

# Dict 1 is just for the purpose of example, you could feed this function
# Any dictionary.

dict1 = {1: 'a', 2: 'b', 3: 'c', 4: 'd'}

dict3 = reversedict(dict1)

print dict3
block01cube is offline   Reply With Quote
Old Mar 8th, 2005, 2:45 PM   #6
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Thank you, that's it. I figured it had to be a loop or some built-in method. Now you can make both dictionaries if you have one of them.
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:05 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC