Using BeautifulSoup, I get a set of data (text) from the site:

text = text.find('div', class_='catalog').text.strip() 

The output is a list:

 Данные 1 Данные 2 Данные 3 

We need to frame this list in the tag <p> . To get the output:

 <p>Данные 1</p> <p>Данные 2</p> <p>Данные 3</p> 

Thank!

Closed due to the fact that the essence of the question is not clear to the participants Enikeyschik , AK , 0xdb , Drakonoved , Kosta B. Jan 17 at 23:02 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

    2 answers 2

    Using f-lines (require python> = 3.6):

     l = ['Данные 1', 'Данные 2', 'Данные 3'] print([f"<p>{i}</p>" for i in l]) 
    • Hello! Your example also frames all the characters in <p> </ p>, and you need a string before the transfer - IZ
    • I do not understand what you are talking about, but I suspect that you simply do not have a "list" (as you said) at the exit, but str . I guess at first it is necessary to bring it really to the list and then to follow the recommendations from the answers. - nobody
    • You are right, led to the list, everything works! Thank! - IZ
     l = ['Данные 1', 'Данные 2', 'Данные 3'] l = list(map(lambda x: '<p>{}</p>'.format(x), l)) 
    • Hello! I tried your example, I’m probably doing something wrong, but I have each character framed in <p> </ p>: text = list(map(lambda x: '<p>{}</p>'.format(x), text)) - IZ
    • @lZ So you said in the question that you got a list, but it turns out you have a string. Convert it to the text.split ('\ n') list - pinguin
    • Yes, you are absolutely right, your example also works. I incorrectly asked a question (I apologize). Thank! - IZ