0

How do you be able to fix one of my codes called "Arabic Numeral Translator" so it works?

See, I am working on that code and I want people to be happy because my code worked. That code is on the coding language that is in the coding language that you see in the tags section.

8th Jul 2017, 2:57 AM
Wyatt
2 Respuestas
+ 4
I've forgotten to specify this important detail in my previous post: Items in dict declaration must be coma (,) separated ^^
8th Jul 2017, 4:27 AM
visph
visph - avatar
+ 3
# your dict declaration isn't right done, put arabics characters inside quotes, use them as keys of your dct (instead as value) # you can put 'normal' digits in quotes also, but you don't need to cast them to string since you don't concatenate them with any string (except the unnecessary -- and error blocking -- in the second print statement of your conditional 'true' branch) # you need to close the parenthesis (rounded brackets): you have missed it in all your 3 print statements Arabic_Numeral={ '١': 1, '٢': 2, '٣': 3, '٤': 4, '٥': 5, '٦': 6, '٧': 7, '٨': 8, '٩': 9, '٠': 0 } message=input() print ("'" + message + "'" + " has been converted into Arabic numerals") for a in message: if a.upper() in Arabic_Numeral.keys(): print(Arabic_Numeral[a.upper()],end="") else: print("<skipped>",end="") # Anyway, as it is, this code works in Python3 local interpreter, but don't work in code playground, at least by replacing your input() call line by: message='٤٢' (I don't know how to type such characters, and so cannot test the code with real input user... but it seems that limitation of user inputs cannot deal with some code pages of unicode (utf-8) :P )
8th Jul 2017, 4:13 AM
visph
visph - avatar