I have made the following modifications. Hopefully the program still
works after all this!
The resulting file is attached below.
1. Trying to eliminate a crash
This crash was caused by making a typing mistake in giving the word
or by trying to find a nonexistent word.
2. Ease of use
I modified the program to drop the requirement of quoting the searchword.
3. Removing 'is'
I believe the use of the 'is' operator the way it is used here
elif input is "a":
, for example, is incorrect.
The 'is'operator is meant to be used to test object identity. See:
the Python Reference Manual, 5.9 Comparisons
This has been discussed a lot on Python forums through the years. The way
'is' is used here makes the correct operation of the program implementation
dependent. See, for example, the thread:
4. Removal of string.join
The reason comes from the Python Library Reference:
4.1.4 Deprecated string functions
The following list of functions are also defined as methods of string and
Unicode objects; see ``String Methods'' (section 3.6.1) for more
information on those. You should consider these functions as deprecated,
although they will not be removed until Python 3.0.
and join() is among these functions.
5. Shortening the program a bit
These are of course matters of style and opinion
Log in to post a comment.