I need help with this program please.
This is a program that will turn your first name into a group of numbers with a being equal to 1 and so on. This program does this but I need to have it total all the numbers in the name. I was told try an accumulator but so far I haven't had any luck.
Thank you


import string
import math


def main():

print ("This is a program that converts a users first name into it's numerical value." )


#get name

name = raw_input("Please enter your name: ")
uname = string.lower (name)

#Use ASCII minus 96 to get numeric values

print "Here is your name code:"
for ch in(uname):
x = ord(ch)-96,
string.sum(x)
print sum(x),

raw_input("Press <Enter> to exit")


main()

Sorry for placing my first post in the welcome center lol. I'm new here.
I need help with this program please.
This is a program that will turn your first name into a group of numbers with a being equal to 1 and so on. This program does this but I need to have it total all the numbers in the name. I was told try an accumulator but so far I haven't had any luck.
Thank you


import string
import math


def main():

print ("This is a program that converts a users first name into it's numerical value." )


#get name

name = raw_input("Please enter your name: ")
uname = string.lower (name)

#Use ASCII minus 96 to get numeric values

print "Here is your name code:"
for ch in(uname):
x = ord(ch)-96,
string.sum(x)
print sum(x),

raw_input("Press <Enter> to exit")


main()

First of all you need to surround your code with the code tags, to achieve something like this:

import math

I think you first try to tabulate your code and the read some documentation about global variables in python. This done, an accumulator will come out pretty straightforward.

best regards,
bc.

I need help with this program please.
This is a program that will turn your first name into a group of numbers with a being equal to 1 and so on. This program does this but I need to have it total all the numbers in the name. I was told try an accumulator but so far I haven't had any luck.
Thank you


import string
import math


def main():

print ("This is a program that converts a users first name into it's numerical value." )


#get name

name = raw_input("Please enter your name: ")
uname = string.lower (name)

#Use ASCII minus 96 to get numeric values

print "Here is your name code:"
for ch in(uname):
x = ord(ch)-96,
string.sum(x)
print sum(x),

raw_input("Press <Enter> to exit")


main()

This article has been dead for over six months. Start a new discussion instead.