#declaring list myList=[12,'Hello','World!'] #for strings print(myList[1][2]) # output --> l #for numbers temp=str(myList[0]) print(temp[1]) # output --> 2
Here is what the above code is Doing:
1. myList[1] is ‘Hello’
2. myList[1][2] is ‘l’
3. myList[0] is 12
4. temp=str(myList[0]) converts 12 to ’12’
5. temp[1] is ‘2’