+ 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

18th Dec 2019, 12:58 PM
mati938
mati938 - avatar
12 Antworten
+ 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.
18th Dec 2019, 1:17 PM
Dennis
Dennis - avatar
+ 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
5th Feb 2020, 8:21 AM
RAHUL SALIYA
RAHUL SALIYA - avatar
+ 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.
19th Dec 2019, 4:11 PM
David Martínez
David Martínez - avatar
+ 1
kashif malhan probably because of the '\b' ?
13th May 2020, 9:05 PM
Dennis
Dennis - avatar
0
Thanks, guess i need to solve it completely different way
18th Dec 2019, 1:22 PM
mati938
mati938 - avatar
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)
20th Feb 2020, 10:37 PM
Steve
0
https://code.sololearn.com/cFJD69j7YpGh/?ref=app I too have same issue but in java, please help !!!
13th May 2020, 8:55 PM
kashif malhan
0
Dennis thanks for replying. I replaced ('\b' ) with (" ") space. Previously all conditions failed but now 4 and 5 , any idea
13th May 2020, 9:20 PM
kashif malhan
0
kashif malhan Not sure, perhaps because your code does not preserve capitals.
13th May 2020, 9:23 PM
Dennis
Dennis - avatar
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 ) "
13th May 2020, 9:32 PM
kashif malhan
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.
13th May 2020, 9:36 PM
Dennis
Dennis - avatar
0
Dennis might be a typo, 😊😊😊
13th May 2020, 9:38 PM
kashif malhan