So I am trying to make a piece if code that can take a string, ignore all plain text in it, and return a list of numbers but I am running into trouble.
basically, I want to turn "I want to eat 2 slices of pizza for dinner, and then 1 scoop of ice cream for desert" into [2,1] (just an example)
dummy = dummy.split(" ")
j = 0
for i in dummy:
dummy[j]=i.rstrip("\D")
j+=1
print(dummy[j-1])
is what i have tried but it didn't remove anything. i tried the rstrip("\D") because i thought that was supposed to remove text but does not seem to work for a list.
any ideas where i went wrong or ways to fix this?
Turn text into a string of letters in python?
Aucun commentaire:
Enregistrer un commentaire