+ 2
No Numerals challenge🙋
Help me out please in no numerals challenge IDk why but it is falling the 3rd (hidden) test and passes all others😕 Here's my code dict={'0':'zero', '1':'one', '2':'two', '3':'three', '4':'four', '5':'five', '6':'six', "7":"seven", "8":"eight", "9":"nine", "10":"ten"} text=input() for key,value in dict.items(): text = text.replace(key,value) print(text)
13 ответов
+ 10
Rambo ,
if you input like :
1 2 3 11 123
the output will be:
one two three oneone onetwothree
the reason is, that you are looking at characters, but it would be better to look for words
▪︎split the input text by space. this gives a list of words.
▪︎then iterate through this list by using a for loop, that gives you one word after the other . you also need a variable for an index number
- check if current word is in the dict.
- if yes
-use dictionary to replace the current element in the list with the help of the index
▪︎finally use join() to put the list to a string and output the string
this should help to solve the exercise
+ 7
Start with ten
dict={"10":"ten",
'0':'zero'...
+ 4
Simba
Thank you
but why what's wrong with the third test , and what happens when we place "10" first in the dictionary
And Isn't there any other way..
+ 4
If input is 10 your code gives onezero instead of ten. Because, it checks keys and values respectively.
+ 3
Simba
Ohh 😅
Tysm
But isn't there another way because what if it need to contain other 2digit numbers
+ 2
Rambo How about this one? :-
for x in input().split():
print(dict.get(x, x), end=" ")
# Hope this helps
+ 2
Jan Novák It's waste of time trying to implement negative numbers!
+ 1
Simba
bro??
+ 1
Ermias Bibi Off-topic comments in the Q&A section will be discouraged. Please post this in your feed instead. I hope it helps.
0
Rambo, are you already done with the third test? If not, my quess is that there is a negative number, I will try to implement negative numbers...
- 1
Guys what is going on here
- 2
Cool
- 3
Anyone interested in showing me the clear differences between phyton , JavaScript and php , I hope you will illustrate your explanation with examples ? One last thing about their critical syntax differences should be included .