Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7717197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:49:35+00:00 2026-06-01T02:49:35+00:00

Somehow the linebreaks are not working as they should. This is what I get:

  • 0

Somehow the linebreaks are not working as they should.
This is what I get:

Expected:
    O meu u2 2 post
    http://www.yahoo.com
    1 Gosto, 0 Nao gosto
    <BLANKLINE>
    O meu u2 post
    http://www.altavista.com
    1 Gosto, 0 Nao gosto
Got:
    'O meu u2 2 post\nhttp://www.yahoo.com\n1 Gosto, 0 Nao Gosto\n\nO meu u2\nhttp://www.yahoo.com\n1 Gosto, 0 Nao Gosto'

This is the code used in the function.
The important parts should be the str and showRecentComments functions

class Comments():
def __init__(self, u=None, text='', link=None):
    self.u = u
    self.text = text
    self.link = link
    self.topo = None
    self.fim = None

def __str__(self):
    actual = self.topo
    s = ''
    if actual == None:
        return None
    while actual != None:
        if actual.seg == None:
            s += str(actual)
            actual = actual.seg
        else:
            s += str(actual) + '\n' + '\n'
            actual = actual.seg
    return s

def add(self,comment):
    if self.topo == None:
        self.topo = comment
        self.fim = comment
    else:
        comment.seg = self.topo
        self.topo.ant = comment
        self.topo = comment

def remove(self,comment):
    actual = self.topo
    if (self.topo == self.fim) and (self.topo == comment):
        self.topo = None
        self.fim = None
    while actual!=None:
        if actual == comment:
            if self.topo==comment:
                actual.seg.ant = None
                self.topo = actual.seg
            elif self.fim==comment:
                actual.ant.seg = None
                self.fim = actual.ant
            else:
                actual.seg.ant = actual.ant
                actual.ant.seg = actual.seg
            break
        else:
            actual = actual.seg

def countLike(self):
    count = 0
    actual = self.topo
    while actual != None:
        if len(actual.likeList) >= 1:
            count += 1
            actual = actual.seg
        else:
            actual = actual.seg
    return count

def showRecentComments(self,n):
    count = 1
    actual = self.topo
    sC = ''
    if actual == None:
        return None
    while actual != None:
        if count < n:
            sC += str(actual) + '\n' + '\n'
            count += 1
            actual = actual.seg
        elif count == n:
            sC += str(actual)
            count += 1
            actual = actual.seg
        elif count > n:
            break 
    return sC

Regards, Nelson Gregório

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:49:38+00:00Added an answer on June 1, 2026 at 2:49 am

    It looks like you’re looking at the representation of the string, which will show you the newline characters as \n. If you print or write to e.g. stdout (sys.stdout.write(s)) the string instead, the newlines will be expanded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on this site: http://www.problemio.com and I have very little clue about
Somehow this call to free() is not working. I ran this application on Windows
Somehow, I cannot get this piece of Smarty code to work as required: {assign
Somehow today when I input: try {} catch {} I get this: try {
Somehow this does not feel like the culmination of the 50 years programming language
I've asked this question as a comment on another post but couldn't get it
Somehow, i don't get it how i can set the height of jScrollPane. http://tinyw.in/BLrg
Somehow I don´t get this at the moment as I want. I get data
Somehow this customer's database didn't update correctly, and now they have some number columns
I want to replace linebreaks with ' ' in PHP. Somehow I can't get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.