# encoding: utf-8 #reating dictionary #if 0 - quit #if terminput - trnslate #you can reaasign value to a key #you can add new key #you can delete key print ''' いらつしやい! 0 - Exit 1 - Enter your English word to get Japanese equivalent 2 - Enter your Japanese word to get English equivalent 3 - Add new Japanese word to dictionary and set it's translation 4 - Change definition of Japanese word in the dictionary 5 - Delete words from dictionary ''' slogodictionary = {'so':'そ', 'wo':'を', 'no':'の', 'to':'と', 'ko':'こ', 'ro':'ろ', 'ho':'ほ', 'mo':'も', 'yo':'よ', 'o':'お', 'a':'あ', 'ka':'か', 'ta':'た', 'sa':'ち', 'ma':'ま', 'na':'な', 'ha':'は', 'ya':'や', 'wa':'わ', 'ra':'ら', 'n':'ん', 'e':'え', 'ke':'け', 'se':'せ', 'te':'て', 'ne':'ね', 're':'れ', 'he':'へ', 'me':'め', 'i':'い', 'ki':'き', 'hi':'ひ', 'ni':'に', 'mi':'み', 'shi':'し', 'chi':'ち', 'ri':'リ', 'u':'う'} t = None t1 = None t2 = None t22 = None slogodictionary1 = None inv_map = {v: k for k, v in slogodictionary.items()} print inv_map print len(inv_map) list1 = slogodictionary.keys() list2 = slogodictionary.values() print list1 #for v in list2: # print v dict2 = {} x = 0 #print len(slogodictionary.values()) while True: if x < len(slogodictionary.values()): term = list2[x] value = list1[x] dict2[term] = value x += 1 print len(dict2) if x == len(slogodictionary.values()): break #while True: # if t != 0: # t = int(raw_input('Enter your choice of action between 0 and 5\n')) # if t == 1: # t1 = raw_input('Enter your English word here\n') # if t1 in slogodictionary: # print slogodictionary[t1] # if t == 3: # t2 = raw_input('Enter you Japanese word with Hiragana symbols\n') # t22 = raw_input('Enter the translation value of this Hiragana word\n') # if t2 not in slogodictionary: # slogodictionary[t2] = t22 # print t2, 'and', slogodictionary[t2], 'has been updated!' # print 'さよなら!' raw_input('\n\nP')
Standard input is empty
いらつしやい! 0 - Exit 1 - Enter your English word to get Japanese equivalent 2 - Enter your Japanese word to get English equivalent 3 - Add new Japanese word to dictionary and set it's translation 4 - Change definition of Japanese word in the dictionary 5 - Delete words from dictionary {'\xe3\x81\xbb': 'ho', '\xe3\x82\x82': 'mo', '\xe3\x82\x81': 'me', '\xe3\x81\xbf': 'mi', '\xe3\x81\xbe': 'ma', '\xe3\x82\x84': 'ya', '\xe3\x81\xb2': 'hi', '\xe3\x82\x88': 'yo', '\xe3\x82\x89': 'ra', '\xe3\x82\x8f': 'wa', '\xe3\x82\x8c': 're', '\xe3\x82\x8d': 'ro', '\xe3\x81\xab': 'ni', '\xe3\x81\xaa': 'na', '\xe3\x81\xb8': 'he', '\xe3\x81\xaf': 'ha', '\xe3\x81\xae': 'no', '\xe3\x81\xad': 'ne', '\xe3\x83\xaa': 'ri', '\xe3\x81\xa1': 'sa', '\xe3\x81\xa6': 'te', '\xe3\x81\x9b': 'se', '\xe3\x81\x9f': 'ta', '\xe3\x81\x9d': 'so', '\xe3\x81\x93': 'ko', '\xe3\x81\x91': 'ke', '\xe3\x81\x97': 'shi', '\xe3\x81\x8b': 'ka', '\xe3\x81\x8a': 'o', '\xe3\x81\x88': 'e', '\xe3\x81\x8d': 'ki', '\xe3\x81\x82': 'a', '\xe3\x81\x86': 'u', '\xe3\x81\x84': 'i', '\xe3\x82\x92': 'wo', '\xe3\x82\x93': 'n', '\xe3\x81\xa8': 'to'} 37 ['me', 'u', 'yo', 'wo', 'mi', 'ra', 'hi', 'ho', 're', 'e', 'ha', 'ri', 'he', 'a', 'ni', 'ka', 'te', 'ma', 'wa', 'ke', 'no', 'i', 'na', 'mo', 'ko', 'ne', 'o', 'n', 'to', 'so', 'ya', 'chi', 'shi', 'sa', 'ro', 'ki', 'se', 'ta'] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 33 34 35 36 37 さよなら! P
Traceback (most recent call last): File "prog.py", line 67, in <module> EOFError: EOF when reading a line