I am a novice python programmer. I was learning and practicing the List data structure in python 3.8. To place my certain query I will take help from the following example.
For example, a list named Numbers has been created below.
Anwarul Kabir
For example, a list named Numbers has been created below.
Numbers=[5,6,3,4,8,9,2,1,7] #Defined a list. print(Numbers[0]) #Output of this statement 5 is understood. print(Numbers[8]) #Output of this statement 7 is understood. #print(Numbers[9]) This would show IndexError: list index out of range and it is logical and understood. print(Numbers[0:8]) #Output of this statement [5,6,3,4,8,9,2,1] is understood as it is mentioned that it works like this. print(Numbers[0:9]) #Output of this statement [5,6,3,4,8,9,2,1,7] is surprisingly worked and understood! print(Numbers[-9]) #Output of this statement 5 is understood. print(Numbers[-9:-1]) #Output of this statement [5,6,3,4,8,9,2,1] is understood as it is mentioned that it works like this. print(Numbers[-9:0]) #Output of this statement [] instead of [5,6,3,4,8,9,2,1,7] is surprisingly not worked and didn't understand! # Or print(Numbers[-9:-0]) #Output of this statement [] instead of [5,6,3,4,8,9,2,1,7] is surprisingly not worked and didn't understand!My query is in the comments of the code of my given example. If anyone expert can help me to clarify this I would be grateful! Thank you.
Anwarul Kabir