#1
  1. No Profile Picture
    inexperienced and useless
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    Stevenage, uk
    Posts
    10
    Rep Power
    0

    adding "\n" to python list items


    I know what I have to do, I want to split a results list from a database query into single lines for formatting reasons. I am however unsure of the syntax of how to do this, if anyone could help it would be very helpful
  2. #2
  3. No Profile Picture
    Python Prophet
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    Amersfoort, The Netherlands
    Posts
    45
    Rep Power
    13
    I'm not sure what you want, but I guess you want to add a newline between every result. Then just use string.join like this:
    Code:
    joined_string = string.join(list, 'n')
    You should import the string module first to use this.
    Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems. - Jamie Zawinski, in comp.lang.emacs

IMN logo majestic logo threadwatch logo seochat tools logo