+ 1

There subscripts of an array can be integer constants, integer variable or expression

why can't we use negative no. or float

19th Feb 2018, 7:39 PM
Sam - avatar
1 Answer
+ 3
Because in array not exist a medium term in arrays ,for example: myList = [1 ,2 ,3 ,4 ,5] # List (array) in Python Not is possible get a value 1.5 that a medium term of 1 and 2 ,only is possible get this value using a float index ,per this that not is possible use the float index. How match the negative number for index ,on some languages is possible use the negative numbers ,such as Python example using the old array. print(myArray[-1]) # Show the value 5 of the array print(myArray[-3]) # Show the value 3 of the array
19th Feb 2018, 8:11 PM
J G - avatar