Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
for instance:(["one", 4, "three", 7]) would come out like:[1,4,3,7]

What I have tried:

def digits(lst):
digits=['two','seven','three','five']
for c in '2735':
s = s.replace(c, digits(int(s)))
return s
Posted
Updated 9-Nov-17 12:05pm
v2

1 solution

Some searching should do the trick:
Converting Text Numbers to Numeric Values[^]

Its in C#, but should be easy to understand.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900