I need to extract data from multiple positions in an array.
A simple array would be:-
listing = (4, 22, 24, 34, 46, 56)
I am familiar with slicing. For instance:-
listing[0:3]
would give me:-
(4, 22, 24)
However I am unable to get out multiple slices. For instance:-
listing[0:3, 4:5]
gives me
TypeError: tuple indices must be integers not tuples
Despite Searching two Python books and the Internet I cannot work out the syntax to use.
listingin your example is tuple not an array. For array you should use array module, or list as closest concept. Difference between tuples and lists that in first elements are immutable. - ailin(4, 22, 24, 34)or((4, 22, 24), (34))? - Someone