Skip to content

Commit ec238f2

Browse files
Merge pull request #163 from codewizardshq/python-docs-add-shuffle
Add `shuffle()` to Python Language docs.
2 parents ec59c2a + d9348ba commit ec238f2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/python/python-language.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,20 @@ random_name = choice(names)
19501950
print(random_name) # dima
19511951
```
19521952

1953+
##### `Shuffling the items in a sequence`
1954+
1955+
The `shuffle()` function can be used to shuffle the items in a sequence (`list` or `str`). The function modifies the original sequence, so there's no return value.
1956+
1957+
```python
1958+
from random import shuffle
1959+
1960+
# Get an integer between 1 and 10
1961+
answers = ["Five", "Seven", "Eight"]
1962+
shuffle(answers)
1963+
1964+
print(answers) # ['Seven', 'Eight', 'Five']
1965+
```
1966+
19531967
_Further Reading_
19541968

19551969
- [The Python Standard Library](https://docs.python.org/3/library/index.html)

0 commit comments

Comments
 (0)