+ 3

Is this python code valid for translation from English to hindi or any modification needed??

from translate import translator translator=Translator(from_lang='english',to_lang='hindi') result=translator.translate('what are you doing') print(result)

12th Feb 2021, 7:47 AM
Arun kumar
Arun kumar - avatar
7 odpowiedzi
+ 1
I have checked your code. This is a bit to test: https://code.sololearn.com/cJWZxHC61ZEN/?ref=app But there is one problem: it installs from PyPI module "translate" that has no module/class/object called "translator". [edit] I have read your code again and noticed that you are trying to import "translator" from "translate", but then using "Translator". Change "translator" to "Translator" in "from translate import translator" and your code runs correctly. I fixed the code.
12th Feb 2021, 9:58 AM
#0009e7 [get]
#0009e7 [get] - avatar
+ 3
Ok dude and thnx😀
12th Feb 2021, 1:02 PM
Arun kumar
Arun kumar - avatar
+ 2
So it will not work! Is there any alternative way to do this task??
12th Feb 2021, 10:07 AM
Arun kumar
Arun kumar - avatar
+ 2
It runs without any errors but gives no output!
12th Feb 2021, 11:24 AM
Arun kumar
Arun kumar - avatar
+ 1
1) Your code is shown not completely because of 128 characters limit of the question title. Try placing code to the description or creating a code bits (new code, copy, paste, save, name) and adding the link to the description. 2) The part of code I see may be valid if there is "translate.py" ("translate") module installed where you run the code.
12th Feb 2021, 9:00 AM
#0009e7 [get]
#0009e7 [get] - avatar
0
Arun kumar, read after [EDIT] of my second comment, I wrote fixing. And visit the code to see the fixed code (doc-string and all the code before "from ... import" is not necessary if you have "translate" module installed).
12th Feb 2021, 10:55 AM
#0009e7 [get]
#0009e7 [get] - avatar
0
Arun kumar, try it again until it gives output! "No output" can happen when runtime is exceeded. And the runtime needed for this code is long because internet connection required.
12th Feb 2021, 11:53 AM
#0009e7 [get]
#0009e7 [get] - avatar