+ 1

Any way to do it more efficiently?

No Numerals You write a phrase and include a lot of number characters (0-9), but you decide that for numbers 10 and under you would rather write the word out instead. Can you go in and edit your phrase to write out the name of each number instead of using the numeral? Task: Take a phrase and replace any instances of an integer from 0-10 and replace it with the English word that corresponds to that integer. Input Format: A string of the phrase in its original form (lowercase). Output Format: A string of the updated phrase that has changed the numerals to words. Sample Input: i need 2 pumpkins and 3 apples Sample Output: i need two pumpkins and three apples https://code.sololearn.com/c533Z8O37qU2/?ref=app

3rd May 2020, 3:45 PM
Fanatic
Fanatic - avatar
4 odpowiedzi
+ 2
You can do it using dictionaries. Replacing the digits with words
3rd May 2020, 4:00 PM
Justus
Justus - avatar
3rd May 2020, 3:56 PM
Abhay
Abhay - avatar
+ 1
Instead of ten variables, you can use one only.. Dictionaries may be help as more readable..
3rd May 2020, 4:08 PM
Jayakrishna 🇮🇳