+ 4
To access a certain value in a string, or list we can print it's index. For example, the string 'cat' has 3 letters. In programming we start counting at 0. So: 'cat'[0] = c 'cat'[1] = a 'cat'[2] = t So in the example you gave, the third character would be found by counting 0, 1, 2. 'hello'[0] = h 'hello'[1] = e 'hello'[2] = l A strings third letter could be returned this way. The same rule applies for a list. To get the third item from a list, you do it like we did with the string
3rd Feb 2022, 10:18 AM
ForgetfulMemoryFoam
ForgetfulMemoryFoam - avatar
+ 1
If you have 'no' idea then revise the lessons you read
3rd Feb 2022, 10:10 AM
NEZ
NEZ - avatar