0
adding digits of a number including characters
what is the program to add sum of digits of a number.for non-numeric,add it's ASCII value. For Eg:if the input is "12a" output should be 100 as ASCII value of a is 97 so 97+2+1 so 100.
2 Answers
- 2
#python
inp='12a'
print(sum([(int(i) if i.isdigit() else ord(i)) for i in inp]))