Split function doubt

if we use a variable name L instead using all-numeric entry if we use some character or string in it then what we can do to convert the all the numeric variable into an integer
eg:
if L = "10 ram 20 30 sham 50 "
to use the statement
number = [int(no ) for no in l.split() ]

Hey @Coder_sash2123, you can refer to the following code to achieve the same :

L = "10 ram 20 30 sham 50"
L = L.split()
for i in range(len(L)):
    if (L[i].isalpha() == False) :
        L[i] = int(L[i])

Hope this helps.
Happy Learning :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.