+ 2
Hi everybody! My name is Kutman, I jus started learn Python, and try to understand this language, I need help with task in below
I had to change all numerals till 10 to word in text,like 3 to "three" . I have found an operator "replace"… I made something like this: string=input() print(string.replace("1", " one").replace ("2", " two").replace("3", " three").replace("4", " four").replace("5", " five").replace("6", " six").replace("7", " seven").replace("8", " eight").replace("9", " nine").replace("0", "zero").replace("10", "ten")) However numeral 10 is no working, prints like "one zero" please help
8 Respostas
0
Hi. Just replace 10 before replacing 1.
Let's suppose we have "01101"
So if we replace 10 first:
01ten1
Then we replace 1 and 0.
+ 3
Нашел, пустые пробелы в кавычках мешали
+ 2
Спасибо, сделал так, все нормально работает, только вот тест не проходит, видно где то ещё у меня есть недочёты,
+ 2
Не пойму какая причина тут?
+ 2
No Numerals +50 XP
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
0
I advise you to try codingame.com for practice and better motivation. There you can find various programming puzzles and contests.
0
Можно ссылку на задачу
0
Не знаю я что не так. Может не zero, а null надо.