First you'll need to learn how to use code tags. As your code stands, it is unreadable because all indentation has been lost. If you use code tags, your code is not only readable, but forum members can easily copy and paste it into their code editors to tinker with.

Code tags go like this:
[code=python] # My code goes between these code tags


If you ever post in another forum you can replace "python" with any other syntax (php, perl, html, java, etc.)

So on a brief over look of your code I'm confused by string.sum() .. What does that do? I don't have a sum() function for the built-in string module. Is this a custom module? Also, I don't think you should bother importing the string module. name = name.lower() will do the same thing.

8 Years
Discussion Span
Last Post by vegaseat

Ouch, you need to study up on Python basics. A lot of errors in your code. Take a look at the corrected code and figure out where you can improve your coding skills ...

def main():
    print ("This is a program that converts a users first name into it's numerical value." )
    # get name
    uname = raw_input("Please enter your name: ").lower()
    # use ASCII minus 96 to get numeric values
    print "Here is your name code:",
    sum = 0
    for ch in uname:
        x = ord(ch) - 96
        sum += x
    print sum

    raw_input("Press <Enter> to exit")

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.