Converting String to Ordinal Value

前端 未结 2 1432
误落风尘
误落风尘 2021-01-29 14:17

I\'m looking to compute the sum of the ordinal values of all the characters of the full name string, and will output this sum.

here is what I have so far.



        
2条回答
  •  日久生厌
    2021-01-29 14:50

    Simply use a for loop like so num=sum([ord(i) for i in c],0) assuming c is "Mary Joe" or the string you want. Also, you should use raw_input if you want the user to give you a string, and for printing use print "your full name is: " + c

提交回复
热议问题