I have an error which says “expected an indented block”
Could you please guide me on how to deal with this error. Thank you:)
Code example:
for ch in f: ( translatedToken = english_hindi_dict[ch] ) if (ch in english_hindi_dict) else (translatedToken = ch)
You are probably mixing tabs with spaces. It looks indented but it really isn’t.
Your code gives me a different error:
Maybe you meant:
Maybe you meant instead:
Both should run just fine, and I expect the second to be faster than the former
They both can be optimized into
translated = str(english_hindi_dict.get(ch, ch) for ch in f)but that’s not the point of the question.