+ 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)
7 Réponses
+ 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.
+ 3
Ok dude and thnx😀
+ 2
So it will not work! Is there any alternative way to do this task??
+ 2
It runs without any errors but gives no output!
+ 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.
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).
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.