Skip to content

Instantly share code, notes, and snippets.

@Jawschamp
Last active September 17, 2022 12:24
Show Gist options
  • Select an option

  • Save Jawschamp/f541f742a2227dfb49ab5557c3cbe9e9 to your computer and use it in GitHub Desktop.

Select an option

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)
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
@Jawschamp
Copy link
Author

Some clean up will be made in a few days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment