Conversation
| else: | ||
| return word.lower() | ||
| elif lang in ['zh', 'ja', 'th']: | ||
| return word |
There was a problem hiding this comment.
Here in the line 16th we can write return word.lower()
There was a problem hiding this comment.
Chinese (zh), Japanese (ja), or Thai (th) these languages don't have notion of upper and lowercase characters. So it returns unchanged.
| word = input("Enter a word: ") | ||
| lang = input("Enter language code (BCP-47): ") | ||
|
|
||
| lowercased_word = lowercase_word(word, lang) |
There was a problem hiding this comment.
if some person will enter any random BCP-47 code which is not existing then it will convert text into lower case but after the output coming how person can know that the language code is correct or not so should should we ask for language inspite of language code?
There was a problem hiding this comment.
Now I have mentioned the code word for every language.
| vowels = set(['A', 'E', 'I', 'O', 'U', 'Á', 'É', 'Í', 'Ó', 'Ú']) | ||
| for i in range(1, len(word)): | ||
| if word[i-1] in ['n', 't'] and word[i] in vowels and word[i].isupper(): | ||
| return word[:i] + '-' + word[i:].lower() |
There was a problem hiding this comment.
This should only be applied at the beginning of a word. nAthair -> n-athair, but if it's "bhurnAthair, then "bhurnathair" is fine.
| import unittest | ||
|
|
||
| def lowercase_word(word, lang): | ||
| if lang in ['tr', 'az']: |
There was a problem hiding this comment.
If "lang" is meant to be a BCP-47 code, you'll need to pick out the language code from the beginning.
No description provided.