+ 1
No numerals, bug ?
I attempted No numerals code coach, my output is Exactly as it's expected to be but i still can't pass it, what's wrong ? https://code.sololearn.com/cY16M9yVD5oO/?ref=app
12 Réponses
+ 4
Don't confuse the text "number characters (0-9)" and "an integer from 0-10".
You're not handling the case if the number is 10 correctly.
+ 3
Try this python code:
sentence = input()
lists = sentence.split(' ')
dicti = {'0':'zero','1':'one','2':'two','3':'three','4':'four','5':'five','6':'six','7':'seven','8':'eight','9':'nine','10':'ten'}
for i in range(len(lists)):
if lists[i] in dicti.keys():
lists[i] = dicti[lists[i]]
str = ''
for i in lists:
str = str+i+' '
print(str)
i had the same problem i just added '10':'ten' in my dictionary variable
+ 2
i had the same problem (but in Python). If you try:
0 1 2 3 4 5 6 7 8 9 10
you get
zero one two three four five six seven eight nine onezero
then just try to begin with the 10. So you won't get that "onezero" problem.
+ 1
kashif malhan probably because of the '\b' ?
0
Thanks, guess i need to solve it completely different way
0
why doesn‘t this work?:
s2 = input()
s1 = s2.replace("2","two").replace("3","three").replace("1","one").replace("4","four").replace("5","five").replace("6","six").replace("7","seven").replace("8","eight").replace("9","nine").replace("10","ten").replace("0","zero")
print(s1)
0
https://code.sololearn.com/cFJD69j7YpGh/?ref=app
I too have same issue but in java, please help !!!
0
Dennis thanks for replying. I replaced ('\b' ) with (" ") space.
Previously all conditions failed but now 4 and 5 , any idea
0
kashif malhan Not sure, perhaps because your code does not preserve capitals.
0
Dennis Thank you very much brother 😊 , now it's solved . I thought it has to be converted to lowercase because it is mentioned in input format
"A string should be in its original form(lowercase ) "
0
kashif malhan glad you got it solved ^^.
Yea, no idea why it says lowercase either, it also fails for me when I change my output to lowercase.
0
Dennis might be a typo, 😊😊😊