+ 2
What is the "index"?
6 ответов
+ 5
In Python:
List is an ordered sequence of values.
Index is the key for each value in the list.
You can use the index to access a certain value from a list.
Index is represented as a pair of square brackets [ ] including an index key after a list.
+ 5
You are talking about list data structure... Hmmmm
Hey, it's pretty simple. These are just the position at which an element is present inside a list.
As you know it is an ordered collection of item that means every element belongs uniquely to it's place inside a list.
https://code.sololearn.com/ccSQs7FiZIlq/?ref=app
+ 3
Index
An index refers to a position within a sequence. This means that you can point to a position in a sequence by using an index. Index are integer values, normally starting with 0, so the first element in a sequence has index [0], the second has index [1]. Index are used inside square brackets [..].
Sequences are strings, lists, tuples. Dictionaries and sets are not sequences because they do not support indexing.
my_str = 'hello'
my_str[0] # -> 'h'
my_str[4] # -> 'o'
my_str.index('e') # -> 1
my_list = ['abc', 'xyz']
my_list[1] # -> 'xyz'
my_list[1][2] # > 'z'
Indexes can also be used to iterate on sequences within loops.
+ 3
Index in arrays, or indexes in database programming ? 🤔
+ 3
Sanjay Kamath I thought of about indexing lists in Python, because there is a tag "lists" and SwitTsoLt has a Python course on 1/3.
+ 1
index are used in array in []