Todos os livros

Profissional

Apps Sobre Coach Entrar Começar a ler

Computer Science · Glossário

O que é Slice?

Definition 21.2 Primary & Middle School Computer Science · Capítulo 21 — Strings

A slice is a part of a string (or of a list) taken by indices: s[a:b] holds the characters from index aa up to index bb, but without bb. Without aa, the slice starts at the beginning; without bb, it goes to the end; s[::-1] walks backwards and gives the string reversed.

Think of the indices as standing between the characters: the slice [a:b] takes what lies between the marks a and b.
Think of the indices as standing between the characters: the slice [a:b] takes what lies between the marks aa and bb.
Ler no capítulo →