I’m trying to turn an inputted user name (Rex Ryan) into a 6 character name (ryanre) and change that to a numbered ID (A=01, B=02, …, Z=26).
I’ve made an attempt at converting a full name into a 6 character name with this:
def converter():
first = raw_input('What is the first name of the user? ')
last = raw_input('What is the last name of the user? ')
first[0:2] = firstname
last[0:4] = lastname
user = lastname + firstname
print user
I keep getting “firstname is not defined” when I run it. Any direction or reading would be helpful; I’d like to do this mostly on my own. If I wanted it written for me I could just download something.
You have your statements backward:
As far as converting the return value to a sequence of numbers, have a look at
ord. It will perform the mapping that you’re describing.