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 :: panda - subset based on column value 
Python :: wait() in python tkinter 
Python :: python write requests response to text file 
Python :: how to merge dataframe with different keys 
Python :: opencv get contours 
Python :: switch columns and rows python 
Python :: python windows take screenshot pil 
Python :: python local server command 
Python :: export sklearn.metrics.classification_report as csv 
Python :: jupyter notebook check memory usage 
Python :: vsc python close all functions 
Python :: how to change web browser in python 
Python :: print last n rows of dataframe 
Python :: Test Speed internet using Python 
Python :: wtform custom validator example 
Python :: python display map 
Python :: nlargest 
Python :: intersection in list 
Python :: os.getlogin() python 
Python :: what is a good python version today 
Python :: fill a list with random numbers 
Python :: pyqt5 change table widget column width 
Python :: how to run single loop iterations on same time in python 
Python :: python download video from url requests 
Python :: python read arguments 
Python :: flask post vs get 
Python :: python define 2d table 
Python :: how to use enumerate instead of range and len 
Python :: django queryset group by sum 
Python :: python live radio 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =