Since you want to iterate in an unusual way, a generator is a good way to abstract that:

def chunks(s, n):
    """Produce `n`-character chunks from `s`."""
    for start in range(0, len(s), n):
        yield s[start:start+n]

nums = "1.012345e0070.123414e-004-0.1234567891.21423"
for chunk in chunks(nums, 12):
    print chunk

produces:

1.012345e007
0.123414e-00
4-0.12345678
91.21423

(which doesn't look right, but those are the 12-char chunks)

Answer from Ned Batchelder on Stack Overflow
๐ŸŒ
EyeHunts
tutorial.eyehunts.com โ€บ home โ€บ python split string by character count | example code
Python split string by character count | Example code
March 7, 2023 - string = 'ABC XYZ PQRS' n = 3 # every 3 characters count res = [string[i:i + n] for i in range(0, len(string), n)] print(res) ... a_string = "abcde" res = [] n = 2 for index in range(0, len(a_string), n): res.append(a_string[index: index + n]) print(res) ... Do comment if you have any doubts or suggestions on this Pytho string split topic. ... All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Discussions

How can I split a string in Python after a specific character count? - Stack Overflow
I apologize if this is a duplicate but I can't seem to find anything out there that involves splitting a string based on a character count. For example, let's say I have the following string: Lorem More on stackoverflow.com
๐ŸŒ stackoverflow.com
Example of Character Count in a String
Example of Character Count in a String. #code: input_string = "programming" ip = " ".join(input_string).split() char_count = {} for i in input_string: if i not in char_count: char_count[i] = 1 else: char_count[i]+=1 print(char_count) #Output: {โ€˜pโ€™: 1, โ€˜rโ€™: 2, โ€˜oโ€™: 1, โ€˜gโ€™: 2, ... More on discuss.python.org
๐ŸŒ discuss.python.org
2
0
January 9, 2024
How does `split()` work?
Question: As per this lesson, we are trying to break apart a word to determine the number of times a sequence of characters is present. One method to solve this is using the .split() method, which Iโ€™ll explain below. Solution: If you check the documentation here, we can learn a bit about ... More on discuss.codecademy.com
๐ŸŒ discuss.codecademy.com
0
2
August 19, 2019
Split Words and Count Characters at Each Position
How would you do this if you did it on paper (i.e. manually counting)? More on reddit.com
๐ŸŒ r/learnpython
11
1
August 23, 2023
๐ŸŒ
TechBeamers
techbeamers.com โ€บ python-string-splitting
Python String Split and More - TechBeamers
November 30, 2025 - In this example, the function str_split_by_count takes the input string and passes the desired character count. It initializes an empty list (result) and a variable (cur_pos) to keep track of the current position in the string.
๐ŸŒ
tutorialpedia
tutorialpedia.org โ€บ blog โ€บ split-string-by-count-of-characters
How to Split a String by Character Count Without Delimiters in Python: A Step-by-Step Guide โ€” tutorialpedia.org
Use range(0, len(string), n) to generate starting indices for each chunk (step = n). For each index i, extract the substring string[i:i+n] (from i to i+n; if i+n exceeds the string length, slicing safely returns the remaining characters). def ...
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ string_split.htm
Python String split() Method
The Python String split() method splits all the words in a string separated by a specified separator. This separator is a delimiter string, and can be a comma, full-stop, space character or any other character used to separate strings.
Find elsewhere
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_string_split.asp
Python String split() Method
Remove List Duplicates Reverse a String Add Two Numbers ยท Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... The split() method splits a string into a list.
๐ŸŒ
HackerNoon
hackernoon.com โ€บ how-to-split-string-every-nth-character-in-python
How to Split String Every Nth Character in Python | HackerNoon
May 31, 2024 - In this article, we will learn three simple ways to quickly split a string into substrings of N consecutive characters each. Let us say you have the following string in Python.
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Example of Character Count in a String - Python Help - Discussions on Python.org
January 9, 2024 - Example of Character Count in a String. #code: input_string = "programming" ip = " ".join(input_string).split() char_count = {} for i in input_string: if i not in char_count: char_count[i] = 1 else: char_count[i]+=1 print(char_count) #Output: {โ€˜pโ€™: 1, โ€˜rโ€™: 2, โ€˜oโ€™: 1, โ€˜gโ€™: 2, โ€˜aโ€™: 1, โ€˜mโ€™: 2, โ€˜iโ€™: 1, โ€˜nโ€™: 1}
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ python | split string and count results
Python | Split String and Count Results - Be on the Right Side of Change
December 2, 2022 - All you have to do is split the string using the split() function and then use the len method upon the resultant list returned by the split method to get the number of split strings present.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-split-string-in-groups-of-n-consecutive-characters
Python | Split string in groups of n consecutive characters - GeeksforGeeks
March 23, 2023 - The simplest way to do is by using a loop and split().Using Loop and split()In this method, we'll iterate through each word in the list using for loop and split it based on given K character using spli
๐ŸŒ
Python Examples
pythonexamples.org โ€บ python-split-string-into-specific-length-chunks
Split String into Specific Length Chunks - 3 Python Examples
In this example we will split a string into chunks of length 4. Also, we have taken a string such that its length is not exactly divisible by chunk length. In that case, the last chunk contains characters whose count is less than the chunk size we provided. str = 'Welcome to Python Examples' n = 4 chunks = [str[i:i+n] for i in range(0, len(str), n)] print(chunks)
๐ŸŒ
Codecademy Forums
discuss.codecademy.com โ€บ frequently asked questions โ€บ python faq
How does `split()` work? - Python FAQ - Codecademy Forums
August 19, 2019 - Question: As per this lesson, we are trying to break apart a word to determine the number of times a sequence of characters is present. One method to solve this is using the .split() method, which Iโ€™ll explain below. Solution: If you check ...
๐ŸŒ
Python Basics
pythonbasics.org โ€บ home โ€บ python basics โ€บ python string split() method
Python String split() Method - pythonbasics.org
Given a sentence, the string can be split into words. If you have a paragraph, you can split by phrase. If you have a word, you can split it into individual characters. In most cases, the split() method will do. For characters, you can use the list method. Practice now: Test your Python skills ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-split-string-into-list-of-characters
Split String into List of characters in Python - GeeksforGeeks
Explanation: This code splits the string s = "hello" into a list of characters by iterating through each character and appending it to the list a. ... Python Tutorial รขย€ย“ Python is one of the most popular programming languages. Itรขย€ย™s simple to use, packed with features and supported ...
Published: April 19, 2025
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ split words and count characters at each position
r/learnpython on Reddit: Split Words and Count Characters at Each Position
August 23, 2023 -

I have a list of 5 letter words (Wordle) and I'm trying to find the most frequent character at each of the 5 positions.

The goal is to be able to see at the 5th position, T is the most frequent letter with 40 occurrences, R is next with 38, etc. Ideally the output would be something like the example below that I manually did in Excel.

I want to learn how to do this programmatically but I'm not sure how to get started. Would I use pandas to import and manipulate the data and then count it somehow? I currently have this in an excel or csv file.

If you can point me in the right direction I would appreciate it. Thank you!

Letter	First	Second	Third	Fourth	Fifth
A	44	81	85	45	19
B	45	3	12	4	3
C	54	10	14	31	11
D	21	3	20	15	32
E	20	52	48	77	120
F	35	0	5	8	7
G	28	7	18	23	9
H	23	48	4	8	30
I	13	41	62	42	3
J	4	1	1	0	0
K	8	3	5	17	30
L	22	60	22	39	36
M	32	10	11	22	10
N	8	32	38	44	22
O	5	83	76	30	21
P	32	14	19	11	17
Q	6	3	0	0	0
R	23	64	42	50	53
S	84	5	14	42	9
T	43	23	27	41	75
U	14	35	40	22	2
V	10	3	12	14	0
W	22	10	6	5	6
X	0	6	2	2	2
Y	3	3	14	1	81
Z	1	0	3	7	2
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-string-split
Python split() Method - GeeksforGeeks
July 1, 2026 - It returns the resulting parts as a list of strings. ... Explanation: s.split(',') splits the string s at every comma and returns a list of the parts ['one', 'two', 'three'].
๐ŸŒ
TestMu AI Community
community.testmu.ai โ€บ ask a question
How to split strings by multiple characters in Python? - TestMu AI Community
January 7, 2025 - I need help with splitting strings into words when there are multiple word boundary delimiters, like punctuation. For example, I have a string: "Hey, you - what are you doing here!?" And I want to split it into a list of words like this: ['hey', 'you', 'what', 'are', 'you', 'doing', 'here'] However, when I use Pythonโ€™s str.split(), it only splits by whitespace and leaves punctuation attached to the words.