Another idea...
...This falls into the idea of being one of my "practice programs".
Convert English into Pig Latin!
I got the idea off of a Magic card from the Unhinged novelty set. (i.e. cards that aren't as "serious" as the regular set) It's called Atinlay Igpay, a creature whose rules text is printed on the card in Pig Latin.
Since I like using Pig Latin, I decided to buy a couple copies of the card, and looking at the card, it somehow hit me to write a program to convert into Pig Latin.
Pig Latin is based on a very simple rule (move the first sound to the end of the word, and add -ay.) So it should be a fairly simple string-manipulation problem, and the main problem will be teaching Python to recognize double-letter sounds such as th-, st-, an d so on.
Even so, I had a simple question for Python Tutor: how to break down a string (the English input) into separate words (which I can run a calculation on. Fortunately, it's a one-line solution.
"This is a multi-word string.".split()
returns ["This", "is", "a", "multi-word", "string"]
Now the words are separate items, which I can process separately. Knowing the simple .split() function, I believe I can figure out the rest.
Use a for loop ("for" each item in the result list: run the word conversion) that contains my copnversion code.
0 Comments:
Post a Comment
<< Home