Name | {} (Curly braces) |
||||
---|---|---|---|---|---|
Examples |
# Initialize a new dictionary with the given key/value pairs element_names = {'H': 'hydrogen', 'He': 'helium', 'Li': 'lithium'} # Curly braces with nothing inside creates an empty dictionary nothing_here = {} # Curly braces with values-only create a new set element_set = {'H', 'He', 'Li'} | ||||
Description |
Curly braces are used to define "dictionary literals," giving you the ability
to declare a dictionary and its contents inside your program. A dictionary
literal consists of a series of key/value pairs, written with a colon
(:) between them, and with each of the key/value pairs separated from
one other with commas. Curly braces are also used to define "sets," or a series of unique keys without values, separated by commas. This is not to be confused with using set() on a pixel. |
||||
Syntax | dict = {key0: val0, ..., keyN: valN} set = {key0, key1, ..., keyN} | ||||
Parameters |
| ||||
Related |
[] (Index brackets) set() |
Updated on Tue Feb 27 14:07:12 2024.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License