insert symbol into the text

Question:

Python.
Need to place the symbol (suppose "@") after every three comas in the text.
For example: text = "Reading practice to help you understand simple texts and find specific information in everyday material. Texts include emails, invitations, personal messages, tips, notices and signs. Texts include articles, reports, messages, short stories and reviews."

That should start, I guess, to divide on comas: st_text = text.split(",") Is that right?
then to add certain symbol after every three got splited lines
Something like that?? – print(‘@’.join(st_text[i:i + 3] for i in range(0, len(st_tex), 3)))

But smth going wrong..

As the result must be: ""Reading practice to help you understand simple texts and find specific information in everyday material. Texts include emails, invitations, personal messages,@ tips, notices and signs. Texts include articles, reports,@ messages, short stories and reviews."

Asked By: NDOd

||

Answers:

The join function removes the commas from the text, so I tried other methods and this works:

text = "Reading practice to help you understand simple texts and find specific information in everyday material. Texts include emails, invitations, personal messages, tips, notices and signs. Texts include articles, reports, messages, short stories and reviews."
formatted_text = ''
count = 0 
for i in text:
    formatted_text = formatted_text + I
    if i == ',':
        count += 1
        if count == 3:
            formatted_text = formatted_text + '@'
            count = 0
print(formatted_text)
Answered By: Anushka.N12
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.