Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrew
intro
Commits
ce9068a4
Commit
ce9068a4
authored
May 07, 2017
by
Tancredi Orlando
Browse files
Add slicing.
parent
7d6a9f7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
day_1.md
View file @
ce9068a4
...
...
@@ -390,6 +390,34 @@ lista = [False, 1, "due", 3.0, 4, 5]
----
### Slicing
-
Permette di formare sottoinsiemi di elementi contigui
-
Bisogna indicare un intervallo di indici, separando inizio e fine con
due punti (
`:`
)
-
L'elemento finale non è incluso
```
>>> lista = [0.0, 1, "due", 3.0, 4, 5, 'sei']
```
```
>>> lista[3:5]
['due', 3.0, 4]
```
-
È possibile indicare tutti gli elementi dall'inizio o fino alla fine di una
lista omettendone l'indice
```
>>> lista[:4]
[0.0, 1, 'due', 3.0]
>>> lista[4:]
[4, 5, 'sei']
```
----
### Unpacking
Estrarre valori da un contenitore
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment