# Scientific Computing with Python - Step 18

For this step:

``````text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
index = alphabet.find(text[0].lower())
print(index)
``````

why the result is 7 not 8? as there are 8 lowercase in Hello World

Can you describe what you think this line does in your own words?

find lower case in alphabet in variable index. Now iâm more confuse.

similar letters donât count.
h.e.l.o.w.r.d

I donât think you quite get what that line does.

What is `text[0].lower()`?

to change them as a lower case? then find them in alphabet variable?

What is âthemâ though? `text[0].lower()` only converts one thing into lowercase.

convert H to h and W to w? so it becomes hello world instead of Hello World, then match them to the variable of alphabet.

Nope.

What is `text[0]`

It started from 0

Can you be a bit more specific? What is the output of this code:

``````text = 'Hello World'
print(text[0])
``````

output: H
H = 0
e = 1
l = 2
l = 3
o = 4

W = 5
o = 6
r = 7
l = 8
d = 9

Exactly, yes. Well just the first part.

And whatâs the output of this:

``````text[0].lower()
``````

output = -1
because it wasnât a lower case.

What does the `.lower()` method do?

What is the output of this:

``````print("Hello".lower())
``````

Test it out in the editor if you arenât sure of the answer. You can test and confirm all of these questions yourself, itâs an open book test.

.lower() is to change all letters to be lowercase.
output = hello ?

where is the editor?

Yes, now what is the output of this:

``````text[0].lower()
``````

The editor is where you type the code for Step 18 that youâre working on.

You could also test in a different editor:
https://www.w3schools.com/python/trypython.asp?filename=demo_ref_string_lower

``````x = text[0].lower()
print(x)
``````

output = h

1 Like

Yes, got it. Now what is the output of this:

``````alphabet = 'abcdefghijklmnopqrstuvwxyz'
print(alphabet.find('a'))
``````

I hope you are seeing the connections now. You can always experiment with this in the editor and print out commands to see what they do. You have to do this or you are walking around blind.

yes, I did the logic first, when I canât find the logic, I tested out in the editor. For this, back to basic, the output is 0 ?

1 Like