Skip to content

Commit 71dcf38

Browse files
Merge pull request jdf#148 from jeremydouglass/jeremydouglass-patch-indexbrackets
indexbrackets.xml: wrap code to 50-wide for page layout
2 parents c44586b + 2f65cdb commit 71dcf38

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

‎Reference/api_en/indexbrackets.xml‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
<image></image>
1313
<code><![CDATA[
1414
# Create a list literal
15-
elements = ["H", "He", "Li", "B", "C", "N", "O", "F", "Ne"]
15+
elements = ["H", "He", "Li", "B", "C", "N", "O"]
1616
17-
# Retrieve a single item from the list with a given index
17+
# Retrieve a single list item with a given index
1818
print(elements[3]) # Prints 'B'
1919
20-
# Negative indexes can be used, and count from the end of the list.
21-
print(elements[-2]) # Prints 'F'
20+
# Negative indexes can be used, and count from
21+
# the end of the list.
22+
print(elements[-2]) # Prints 'N'
2223
23-
# Assign a new value to an existing element of a list:
24+
# Assign a new value to an existing list element:
2425
elements[4] = 'Si'
25-
print(elements) # Prints ['H', 'He', 'Li', 'B', 'Si', 'N', 'O', 'F', 'Ne']
26+
print(elements)
27+
# Prints ['H', 'He', 'Li', 'B', 'Si', 'N', 'O']
2628
2729
]]></code>
2830
</example>
@@ -31,8 +33,8 @@ print(elements) # Prints ['H', 'He', 'Li', 'B', 'Si', 'N', 'O', 'F', 'Ne']
3133
<image></image>
3234
<code><![CDATA[
3335
34-
# You can use index brackets with strings as well, to access individual
35-
# characters by index:
36+
# You can use index brackets with strings as well
37+
# to access individual characters by index:
3638
message = "Now is the winter of our discontent"
3739
print(message[0]) # Prints 'N'
3840
print(message[-1]) # Prints 't'
@@ -45,13 +47,15 @@ print(message[11]) # Prints 'w'
4547
<image></image>
4648
<code><![CDATA[
4749
48-
# Index brackets are used to retrieve the value for a given key from a
49-
# dictionary
50-
element_names = {'H': 'hydrogen', 'He': 'helium', 'Li': 'lithium'}
50+
# Index brackets are used to retrieve the value
51+
# for a given key from a dictionary
52+
element_names = {'H': 'hydrogen',
53+
'He': 'helium',
54+
'Li': 'lithium'}
5155
print(element_names['He']) # Prints 'helium'
5256
53-
# Overwrite the value of an element, or add a new key/value pair, by assigning
54-
# to the key:
57+
# Overwrite the value of an element, or add a new
58+
# key/value pair, by assigning to the key:
5559
element_names['Be'] = 'beryllium'
5660
print(element_names['Be']) # Prints 'beryllium'
5761

0 commit comments

Comments
 (0)