Title of the article Python Introduction Subheading
Title of the article It's hard. Subheading
Title of the article What could it be? Subheading
How do we find a string that changes from the string above, such as "Python Introduction," "Difficult," and "What is it?" The function is a non-writeable condition. Is there any way to do it with basic commands only?
python
I think you can find the first four letters to the third letter from the back.
mystr = 'The title of the article is difficult Subhead
print(mystr[4:-3])
The work of finding differences in random text has been widely studied and as a result, tools such as diff have been invented to compare two strings (or files). This uses an algorithm that applies editing distance (http://hsp1116.tistory.com/41), and there are many libraries that have already been implemented directly, so you can use them. Python has a difflib, so you can use this.
© 2024 OneMinuteCode. All rights reserved.