0

No numerals

Why does this code not work: https://code.sololearn.com/c57OPnrn9EX0/?ref=app

2nd Apr 2021, 7:37 PM
Ash 07
Ash 07 - avatar
3 Answers
+ 1
Error is list append() method does not return anything.. It reflect on original list. So final.append("10") modify final list. Return none. So assigning to final = final.append("10") makes final list none. Just use final.append("10") But this code , just splitting to list only.. What is your logic?
2nd Apr 2021, 7:49 PM
Jayakrishna 🇼🇳
+ 1
Im still a begginer at coding and so its all i know, what is the better way?
2nd Apr 2021, 9:13 PM
Ash 07
Ash 07 - avatar
+ 1
Just go on your logic first then go for optimize. Iam not understood your logic so i cant suggest more on that. But only say that input is text with like sample abc 0 1 9 10 ef Here, your for loop take charecter by charecter, you can change 0 - 9 but not 10. text[i] == 10 never true, because it wont take 10, it take '1' next '0'. Hope you understood, list.append() work. I would do like, take input and split with space.. Next in list , values 0 to 10 if any, just replace with text. This can be done in many ways.. Use of a dictionary will simplifies code.
2nd Apr 2021, 9:27 PM
Jayakrishna 🇼🇳