+ 1

How system derive data based on numbers in Pythons

words = ["hello"] words.append("world") print(words[1]) Answer: world so want to understand how system derive data based on position as we have many letters in this word but system picked up exactly the same so explain me the logic behind it?

16th Sep 2020, 12:47 PM
Abhi
Abhi - avatar
1 Answer
+ 3
In python numbers count from 0. print (words[0]) is the first word in your list: "hello". print (words[1]) is the second word in your list: "world". If you are looking for a letter in the word then you need to say this by choosing the word and then adding another parameter: print(words[0][0]) will print the first letter of the first word in your list.
16th Sep 2020, 2:11 PM
Olivia
Olivia - avatar