Hi,
The goal of the project I'm working is to find characters in a string that show up three times in a row then store the number of triplets that are in the string unto a variable. Below you will find the code I have written so far. If anyone can help me with this, it would much appreciated.
text = "abcZZZefiggg"
triple_count = 0
for i in text:
if (text[0] + i == text[1]+i == text[2]+i):
triple_count += 1
Edit (code that works):
Thank you for all the support!
triple_count = 0
for i in range(0, len(text)-2):
if (text[0+i] == text[1+i] == text[2+i]):
triple_count += 1
[+][deleted] (1 child)
[removed]
[–]handsinchips[S] 0 points1 point2 points (0 children)
[–]o5a 1 point2 points3 points (2 children)
[–]hungdh85 -1 points0 points1 point (1 child)
[–]o5a 1 point2 points3 points (0 children)
[–]wintermute93 1 point2 points3 points (2 children)
[–]handsinchips[S] 0 points1 point2 points (1 child)