Jul-24-2022, 02:52 PM
(This post was last modified: Jul-24-2022, 02:52 PM by rob101.
Edit Reason: Formatting
)
(Jul-24-2022, 12:11 PM)giddyhead Wrote: Hi,
Thanks for the reply with information and help. Unfortunately it finds all the numbers within. The numbers in bold below is what I am looking to get rid of. The following is a sample but contains the format of the text in one of the lists which contain numbers throughout:
Hope it clarifies. Thanks in advance.
25 - not this number
the cow just over the moon and the sun is in 1the sky
26 - not this number
5one day is soon and soon is near take 5529care, 30over and out
59 - not this number
The covers at near the back of the 59closet, and when found have them place on the each of the beds. However you see the pillow cases use the ones on the 9second shelve.
No worries. The point of my post (sorry that I wasn't clear on this) is that once you know the position of the digits, you can then use that as first step to building the rest of your script and produce whatever output you like, so more a proof of concept really.
What code do you have so far?
Maybe a better way would be to have two functions (one to find the digits and one to find everything else) and have them work together, in a 'for loop' or a 'while loop', with 'if/else' branches to process the results.
def fdigit(d): digit = re.search('\d',d) if digit: return 1 def fchar(c): char = re.search('\D',c) if char: return 1I've no idea what you're skill level is. Is this something that you're going to be able to do, or will you need guidance?
edit: in fact one function will suffice: if the digit test fails, then there's no need for the other test.
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein