(Jul-25-2022, 05:27 AM)giddyhead Wrote: Yeah looking for a way to get rid of the numbers attached to words using the code from web scrapping.
Okay. That code from your web scrapping, as you call it, is not in a style that I work with, as you may gather from what I've posted.
As for getting rid of the numbers attached to words, that is precisely the objective of my posted script, given that said number is prefixed.
Maybe this is a 'Language barrier' issue. Do you fully understand English?
edit for p.s
I've updated the my code, as I was unhappy about some of the object names that I used (it was developed on-the-fly) and as I'll be adding this code to my notes, I've cleaned it up.
#!/usr/bin/python3 import re def f_number(num): number = re.search('\d',num) if number: num_list = re.split('\d',num) return num_list[-1] input_string = "" # put your text in this string object string_list = input_string.split(' ') p_string = '' for get_word in range(len(string_list)): word = string_list[get_word] number = f_number(word) if not number: p_string += word+' ' else: p_string += number+' ' print(p_string)
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