0
NO NUMERALS how to make it cleaner or more elegant
letters = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"] sentence = input() def transform(phrase): for x in range(11): if str(x) in phrase: pos = phrase.index((str(x))) phrase[pos] = letters[x] return phrase def manip(item): new_list = transform(item.split()) return ' '.join(new_list) print(manip(sentence))
2 Antworten
+ 5
I think, manip doesn't do enough to be a function of its own.
Just convert the string to a list directly in transform, then return ' '.join(phrase).
+ 2
Thanks for the feedback!