Last active
September 17, 2022 12:24
-
-
Save Jawschamp/f541f742a2227dfb49ab5557c3cbe9e9 to your computer and use it in GitHub Desktop.
Get position of a character (clarity and testing purposes a 1 is added to each position)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def char_pos_parser(parse_string: str, pattern: str): | |
| array_data = [] | |
| dict_ = {} | |
| for i in enumerate(parse_string): | |
| array_data.append(i) | |
| for data in array_data: | |
| if data[-1] == pattern: | |
| pos = int(data[0]) + 1 | |
| char = data[1] | |
| print(f"pos: {pos}, char: {char}, occurences: {len(dict_) + 1}") | |
| dict_[pos] = char |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some clean up will be made in a few days