[Tutor] numbers from a name

ZIYAD A. M. AL-BATLY zamb at saudi.net.sa
Sun Sep 25 13:04:28 CEST 2005


On Sun, 2005-09-25 at 01:06 -0400, Goofball223 at wmconnect.com wrote:
> How could I change the program to accept something like: John Bob
> Zelle Python or Kip Rada? 
>
If it works for you with one word, all you need to make it accepts more
is to add the space character " " with a weight of zero to "table".
  >>>    table[' '] = 0

Alternatively, while creating the whole "table":
        table = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7,
        'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14,
        'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21,
        'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26, ' ': 0}

Likewise, you could add the ',' (also with a weight of 0) for names like
"Bob, Bob".

Ziyad.



More information about the Tutor mailing list