Chandan Nick
Chandan Nick

Reputation: 31

Unable to format the response string to ordered list

I have submitted like this enter image description here

But i am getting like this enter image description here

Although the response is same as request i am sending to save about us. But didn't know how to render on webpage correctly.

{
    "fullName": "Chandan nick",
    "totalProducts": 4,
    "totalReviews": 0,
    "aboutus": "<ol>\n<li>Hi</li>\n<li>This&nbsp;</li>\n<li>is&nbsp;</li>\n<li>about&nbsp;</li>\n<li>us</li>\n</ol>",
    "minMonthProd": null,
    "maxMonthProd": null,
    "tagLine": " "
}

I am confused , how this is happening. Please help me out.

Upvotes: 0

Views: 38

Answers (1)

Aman Jangra
Aman Jangra

Reputation: 1

response_str = "Here are the steps:\nStep 1: Do this.\nStep 2: Do that.\nStep 3: Do the other thing."

response_list = response_str.split('\n')

response_list.pop(0)

for I in range(len(response_list)):
    response_list[i] = f"{i+1}. {response_list[i]}"

ordered_list_str = '\n'.join(response_list)

print(ordered_list_str)

Upvotes: 0

Related Questions