How to find all positions of a character in a string in Python?
test = 'canada#japan#uae' c = '#' print([pos for pos, char in enumerate(test) if char == c])
Output
[6, 12]
test = 'canada#japan#uae' c = '#' print([pos for pos, char in enumerate(test) if char == c])
[6, 12]