3. Language Processing and Python: Strings and Control.
Before Class (code)
Practical work (code)
In IDLE do this:
>>> abc_list = ["aaa", "bbb", "ccc"]
>>> abc_list[-1] = "ddd"
Then do this and compare:
>>> abc_string = "abc"
>>> abc_string[-1] = "d"
How could you test a given string to check if it is a palindrome?
palindrome "a word or phrase that reads the same backward as forward." (WordNet 3.0)
The "Word Comparison Operators" in NLTK 1.4:
Back to Python: Making Decisions and Taking Control
are already defined and ready to use.
How would you make these tests if they were not already
defined? Select one of the operators and write some
Python code that does the same test. Think a little bit about weird input.
HG2051: Language and the Computer Francis Bond.