So what I am trying to do is take a group of sentences that each have their own lines, and change certain words in all of the sentences based on a condition. I am trying to take the title (the first line of the text), and any word in the following lines that contains the second letter of the title should be reversed.
So here's an example of a paragraph of words I could use:
"Humpty Dumpty Humpty Dumpty sat on a building Humpty Dumpty had a great summer All the eggs's dogs and all the eggs 's friends Couldn't put Humpty Dumpty back together again."
The second letter of the first line is 'u' so any word with that letter on the next lines should be reversed, like 'building,' 'summer,' etc. How would I write a code that would do this? I'm a relatively new python learner, so keeping it simple would be great - thanks!
Aucun commentaire:
Enregistrer un commentaire