Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Data Science by (18.4k points)

I would like to convert the string to an integers as shown below, separated by "." with a=1,b=2,...z=26

text = 'Hello World"

Expected output:

     H.E.L .L. O  W. O. R. L. D


#split the words

text ="Hello world"

text = text.upper()

splitted_text = text.split(" ")

#map characters to integers

import string

for x, y in zip(range(1, 27), string.ascii_lowercase):

    print(x, y)

I don't know how do I proceed from here.

1 Answer

0 votes
by (36.8k points)

Use the below code:

text = "Hello World".lower()

li = []

for i in text:

    if i!=' ':




 If you want to know more about the Data Science then do check out the following Data Science which will help you in understanding Data Science from scratch

Browse Categories