You mean something like this ...

def letval(x):

a = 77

# you can just use

Edited 7 Years Ago by vegaseat: n/a

No I don't mean that, that would be stupid.
every letter of the alphabet represents a number
a = the first letter = the first number = 1
b = the second letter = the second number = 2
so if I did:

letval(a) #=1
letval(g) #=7 because g is the seventh letter in the alphabet

Edited 7 Years Ago by Kruptein: n/a

hm okay, but in that case I have to make a difference between caps and lowercase letters,... but I will work with that.

Convert them all to lower case before using ord:

l =  l.lower()

Edited 7 Years Ago by scru: n/a

If you are only interested in the letter's position in the alphabet, you can use something like this ...

import string

def letter_position(letter):
    ucase = string.uppercase
    pos = ucase.find(letter.upper()) + 1
    if pos:
        print( "%s has position %d in the alphabet" % (letter, pos) )

letter_position('8')  # a number gives no response

Edited 7 Years Ago by vegaseat: n/a

This question has already been answered. Start a new discussion instead.