Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
What methods are there to extract what the user wrote character by character?

I am a beginner in Python, I try to extract from an input what I wrote but I need to extract it in parts, a method that can extract a number of characters that I tell it, I have used this:

 código = input() extraer_subcadena1 = código[0:1]

However I want each passing through the while loop to change to a different number of characters and I can't do it because I don't know how to make an algorithm that can change this [0:1] to for example this [1:2] each passing for the while loop

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

for this case I recommend you read about the for loop https://j2logo.com/loop-for-en-python/

for this algorithm what you want is to print an index of the string starting from 0 and ending at the last letter.

First: to know when it measures a string in python, use the len method on a text string. for example I have the string variable and I want to know how many characters it measures then, using the I have method:

 cadena = "Hola Mundo" print(len(cadena)) ## El resultado es 10

Once As knowing measuring chain using the cycle is for so that use in this manner (eye, as is an input of the user and does not know how tall is assigned the value of the method len a variable)

 codigo = input('Introduce un texto: ') longitud = len(codigo) for letras in range(longitud): #Esta parte se puede simplificar pero haciendolo de este modo podras ver mejor como funciona print(codigo[letras:letras+1])

and as output it will give you:

 H o l a M u n d o
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda