Skip to content
Advertisement

How do i convert a modified list of The Alphabet into a number?

i want to convert the sentence from variable (salam) into numbers. The conversion table is like a modified alphabet just like in (char2). My expected output is a 3×3 matrix, inside is the converted number from(salam) using (char2)

salam = "APAKABARBROOOOO"
salam = salam.lower
output = []
char2 = [' ','a','b','c','d','e','f','g','h','i','j','k','l',
               'm','n','o','p','q','r','s','t','u','v','w','x','y','z','.',',']
i = 0
while i <= 15:
    np.array(char2.index(salam[i]))
    i = i+1

and the output is

Traceback (most recent call last):
  File "C:Usersdraggtesting funtction losaot[sn[gamain.py", line 12, in <module>
    np.array(char2.index(salam[i]))
TypeError: 'builtin_function_or_method' object is not subscriptable

here is the image for clarity enter image description here

Advertisement

Answer

The problem is from salam.lower. It should be salam.lower(). Without the () you are just referencing the .lower object.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement