Square brackets
Square brackets are paired punctuation marks used in programming-language syntax to delimit expressions or constructs, including indexing and collection literals.
Statistics Slam Dunk
An extraction operator is syntax that selects a subset of elements from an R vector, matrix, array, list, or data frame.
- How it is used
- Uses indexing to select data-frame columns for calculations and replace invalid vector values before analysis.
- How deep it goes
- Defines extraction operators and demonstrates positional selection, conditional selection, indexed assignment, and validation.
- Examples
- Demonstrates selecting salary and win columns, calculating team summaries, and replacing 227 negative win-share records.
- What you can do after
- Diagnose and correct selected R values while extracting columns for practical NBA data summaries.
Get Programming: Learn to code with Python
Square bracket notation is Python syntax that places an index or slice specification inside brackets to access part of a sequence.
- How it is used
- Accesses elements in lists and characters or substrings in strings.
- How deep it goes
- Defines indexing, negative positions, slicing syntax, and out-of-range errors through short examples and checks.
- Examples
- Uses grocery lists, “Python rules!”, student records, character indexes, and quick-check expressions.
- What you can do after
- Apply it in Python to create lists, retrieve sequence items, slice strings, and recognize invalid list indexes.
Read how Get Programming: Learn to code with Python explains square brackets →
Related concepts
- listuses · A list is an ordered collection of elements arranged in a sequence.
- __getitem__equivalent to · __getitem__ is a Python special method that defines subscription access to an object's elements using square-bracket notation.
- array literaluses · An array literal is source-code syntax that directly specifies the elements of an array.
- dotted notationalternative to · Dotted notation is syntax that uses periods to access or invoke members, qualify names, or represent hierarchical paths.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

