October 2004
Intermediate to advanced
336 pages
6h 27m
English
This function encodes strings using a simple character map. Letters are mapped to the letter that is 13 positions away in the alphabet, so A becomes N (and N becomes A), B becomes O, and so on. In addition, numbers are mapped to the symbol that occupies the same key on a standard U.S. keyboard, so 1 becomes !, 2 becomes @ (and vice versa), and so on. Other characters are left alone.
The built-in function index(), when called on a string, returns the index in the string of the first occurrence of a substring: It raises a ValueError exception if the substring is not found:
location = index("hey there", "th") ...Read now
Unlock full access