About 551,000 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 …

  4. python - How to iterate over each string in a list of strings and ...

    Jan 7, 2014 · If the first and the last element in the string is the same, then increment the count. If I try it manually, I can iterate over each element of the strings in the list:

  5. 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, …

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

    Oct 12, 2015 · 13 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 …

  7. 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): ...

  8. python - how do i loop through all the letters in a string and see if ...

    Jan 24, 2023 · I have a string and i need to loop through all of its letter including (if there's any) white spaces, numbers, symbols, etc... I have to make sure that the string only contains letters, but my …

  9. python - How to iterate string/arrays - Stack Overflow

    Python's list is the actual counterpart to "arrays" of C++ or Java. And technically, Python does not have an array data type, but it has an array module.

  10. python - Iterating through a string word by word - Stack Overflow

    Aug 6, 2015 · The problem for the code above is it counts each letter in a string, instead of each word. To solve this problem, you should first turn the string into a list by using the split () method, and then …