About 50 results
Open links in new tab
  1. Iterating each character in a string using Python

    Aug 29, 2022 · How can I iterate over a string in Python (get each character from the string, one at a time, each time through a loop)?

  2. How do I iterate through a string in Python? - Stack Overflow

    The question you've asked (how to iterate through the alphabet) is not the same question as the problem you're trying to solve (how to count the frequency of letters in a string). You can use …

  3. Iterate over a string 2 (or n) characters at a time in Python

    Jul 22, 2009 · Earlier today I needed to iterate over a string 2 characters at a time for parsing a string formatted like "+c-R+D-E" (there are a few extra letters). I ended up with this, which works, but it looks

  4. python - Iterate over the lines of a string - Stack Overflow

    It would be better just to read the string from a file, which already allows you to iterate through it as lines. However if you do have a huge string in memory already, one approach would be to use StringIO, …

  5. Python - Create string with for-loop - Stack Overflow

    Sep 16, 2018 · As a beginner to Python I got these tasks by the teacher to finish and I'm stuck on one of them. It's about finding the consonants in a word using a for-loop and then create a string with those …

  6. How do I append one string to another in Python?

    Dec 14, 2010 · For handling multiple strings in a list, see How to concatenate (join) items in a list to a single string. See How do I put a variable’s value inside a string (interpolate it into the string)? if …

  7. Iterate through python string starting at index - Stack Overflow

    Oct 12, 2015 · If I have a very long string (say 100 million characters), is there a way to iterate through the characters using something like for c in str: but starting a certain number of characters in? I'd pr...

  8. Best way to loop over a python string backwards

    Aug 9, 2015 · What is the best way to loop over a python string backwards? The following seems a little awkward for all the need of -1 offset: string = "trick or treat" for i in range(len(string)-1, 0-1, -1): ...

  9. How do I reverse a string in Python? - Stack Overflow

    There is no built in reverse method for Python's str object. How can I reverse a string?

  10. Python - loop through the characters of a string until length of string ...

    Dec 14, 2022 · 0 I'm trying to write a function that takes two strings (message and keyword) and where the latter is shorter than the former, loop over the characters in it so that the length of both strings are …