Discussion about this post

User's avatar
Greg's avatar

print( [i for i in text if i.isnumeric()] )

Expand full comment
Andy Au Lugo's avatar

#Extract All Digits From a String in Python

text = "The year is 2025 and the time is 09:45."

num = []

for i in text:

if i.isdigit():

num += i

print(num)

Expand full comment

No posts