Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

extract numbers from string python

# Python program to extract digits from string

# take string
string = "kn4ow5pro8am2"

# print original string
print("The original string:", string)

# using join() + filter() + isdigit()
num = ''.join(filter(lambda i: i.isdigit(), string))

# print extract digits
print("Extract Digits:", num)
 
PREVIOUS NEXT
Tagged: #extract #numbers #string #python
ADD COMMENT
Topic
Name
6+8 =