Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Convert Letters to Numbers in Python Using list comprehension

Convert Letters to Numbers in Python using list comprehension
text = "itsmycode"

# elegant way using list comprehension
num_list = [ord(x) - 96 for x in text]

# print the converted letters as numbers in list
print("After converting letters to numbers", num_list)
Source by itsmycode.com #
 
PREVIOUS NEXT
Tagged: #Convert #Letters #Numbers #Python #Using #list #comprehension
ADD COMMENT
Topic
Name
7+1 =