Scientific Computing with Python - Step 18

Perfect yes.

Why is the output 0?
And back to your original question, why is the output 7?

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

The output 0 because ‘a’ is the first letter in the alphabet variable.
output 7 because h is number 7 in the alphabet variable.

for this code (also my question before):

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

output = 7

1 Like

You got it :muscle: nice work

1 Like