0Pricing
NLP Academy · Aula

Convertendo para minúsculas e removendo espaços

Seus primeiros passos de normalização.

Convertendo para minúsculas e removendo espaços é uma aula grátis de NLP Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de NLP Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de NLP Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Your First Two Steps

The simplest normalization is folding case and trimming spaces. Master these two and you already remove most of the noise that splits your word counts. ✨

Lowercasing in One Call

Python strings carry a built-in lower method. It returns a fresh copy with every letter folded to lowercase, leaving the original untouched.

text = 'The QUICK Fox'
print(text.lower())

Now They Match

Once both sides are lowercased, the case difference vanishes and the comparison finally returns True. That is the whole point of case folding.

print('Paris'.lower() == 'paris')

Trimming the Edges

The strip method removes whitespace from both ends of a string. Leading and trailing spaces, tabs, and newlines all disappear in one call.

messy = '  hello world  '
print(messy.strip())

One-Sided Trims

Sometimes you only want one edge cleaned. Use lstrip for the left side and rstrip for the right when you need that control.

print('  hi'.lstrip())
print('hi  '.rstrip())

Spaces in the Middle

Strip only touches the ends. To squash repeated spaces inside text, split on whitespace and rejoin, which collapses every gap to a single space.

text = 'too    many   spaces'
print(' '.join(text.split()))

Why Split Then Join

Calling split with no argument breaks on any run of whitespace and drops the empties. Rejoining with one space gives you clean, even spacing.

Chain Them Together

Because each method returns a string, you can chain them. Here you lowercase and strip a value in a single readable pipeline.

raw = '  CoddyKit  '
print(raw.lower().strip())

Strings Are Immutable

These methods never change the original; they hand back a new string. Always capture the result in a variable or you lose the cleaned value.

s = 'HELLO'
s.lower()
print(s)

Normalize a Whole List

Apply your two steps to every token at once with a comprehension. Now each word is lowercase and trimmed, ready for counting.

words = [' Cat ', 'DOG', 'Cat']
print([w.lower().strip() for w in words])

Counts Finally Agree

After folding case, the three messy entries for cat collapse into one matching token, so your frequency table tells the truth. 📊

Quick Check

Let's confirm how to clean spacing.

Recap

You learned to fold case with lower and trim edges with strip, then collapse inner gaps with split and join. Your tokens now match cleanly. Nice work! 🎉

Perguntas Frequentes

A aula “Convertendo para minúsculas e removendo espaços” é grátis?

Sim — o texto completo de “Convertendo para minúsculas e removendo espaços” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de NLP Academy, atualize para CoddyKit PRO. O curso de NLP Academy inclui 4 aulas no total.

O que vou aprender em “Convertendo para minúsculas e removendo espaços”?

Seus primeiros passos de normalização. Você pratica NLP Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar NLP Academy?

Nenhuma experiência prévia é necessária. NLP Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.

Quanto tempo leva a aula “Convertendo para minúsculas e removendo espaços”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de NLP Academy?

Sim. Cada aula de NLP Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Por que maiúsculas e espaçamento importam
  2. Convertendo para minúsculas e removendo espaços
  3. Stemming: reduzindo à raiz
  4. Lemmatização: formas básicas mais inteligentes
← Voltar para NLP Academy