Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!