Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Convert Letters to Numbers in Python

Convert Letters to Numbers in Python using ord() method
text= "itsmycode"
num_list = []

# iterate each characters in string
# and convert to number using ord()
for c in text:
   num_list.append(ord(c) - 96)

# print the converted letters as numbers in list
print("After converting letters to numbers",num_list)
Comment

letters to numbers python

letters = "zjkswa"

numbers = [ord(l) - 96 for l in letters]

print(numbers)
Comment

PREVIOUS NEXT
Code Example
Python :: time difference between two datetime.time 
Python :: declare empty var python 
Python :: how to add a file to an email in python 
Python :: pandas resample groupby 
Python :: ascending, descending dict 
Python :: how to add to the end of an array python 
Python :: dataframe to pandas 
Python :: messagebox python pyqt 
Python :: convert .py to .ipynb file 
Python :: gradient boosting regressor 
Python :: replace all characters in a string python 
Python :: Math Module ceil() Function in python 
Python :: python calculator file size to megabytes 
Python :: Iterate through string backwards in python 
Python :: subtract list from list python 
Python :: Drop multiple columns by name 
Python :: readlines replace  
Python :: python string cut 
Python :: Python Tkinter Button Widget 
Python :: beautifulsoup find element by partial text 
Python :: ordered dictionary 
Python :: openai gym random action 
Python :: remove na python 
Python :: python datetime greater than now 
Python :: list of dicts 
Python :: turtle with python 
Python :: activate internal logging nlog 
Python :: pandas df represent a long column name with short name 
Python :: pygame.events 
Python :: pandas reset index from 0 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =