0
find ints in a string
we have a string like this: *abcd*12*abcd*874647*abcd*837*abcd* and i wwnt to work just with ints.how i can seprate them?
2 Answers
+ 2
no idea how you are planning on using them since your question wasnt explained fully.
here is one way
https://code.sololearn.com/cnFfxqp4by0c/?ref=app
+ 1
It is simple.
First, you need to split your string into entries (devided by "*").
Second, you need to check evey entry you got if it is an in integer.
So, you need something like this:
astring = "*abcd*12*abcd*874647*abcd*837*abcd*"
entries = astring.split("*")
for entry in entries:
try:
print(int(entry))
except:
pass
The result is:
12
874647
837