How to convert letters to numbers using python -
i want convert letters numbers along special characters , numbers remaining is.
code:
input = raw_input('insert string: '); output = []; character in input: number = ord(character) - 96; output.append(number); print output;
i can convert alphabets letters, when input numbers, it's showing negative numbers.
any suggestions? in advance!
i guessing code using , other link gave in question -
print [ord(char) - 96 char in raw_input('write text: ').lower()]
this , found out in example, convert characters unicode counterparts,if not want want convert numbers can use following -
>>> print ''.join([str(ord(ch) - 96) if ch.isalpha() else ch ch in raw_input('write text: ').lower()]) write text: abcd123 @!#as1 1234123 @!#1191
Comments
Post a Comment