Text and Number Separation

Hi All,

Is it possible to separate a list into numbers and texts? So numbers are in a separate lists and the text are also in separate lists. Cheers

Hi there,
Yes in python you can do this like this:

mixed_list = ["user", "2", "6", "62", "Graham"]
numbers = [x for x in mixed_list if x.isdigit()]
texts = [x for x in mixed_list if not x.isdigit()]
1 Like

Hi Graham,

Thanks for you reply, really appreciated. My follow up question would be, how do i use an external list similar to the attached? As Python does not automatically see the attached data s a list

I think you need to specify a type on the input to tell it that is a list

I changed the hint to List Access but it still doesn’t read it as a list
test text.gh (6.4 KB)

You were missing a few things.

You can do that

test text.gh (8.7 KB)


Thank you both, it works now. Just to understand the logic, can you or @Dancergraham explain the x for x to me please. Many thanks

That’s a FOR loop.

1 Like

Yes it is called a list comprehension