By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,996 Members | 1,498 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,996 IT Pros & Developers. It's quick & easy.

Printing each item of a list on a separate line?

P: n/a
Hi! I'm trying to print a list that contains names and when it prints the items in the list all print on the same line. What I want is for each name to print on its own line.

For example this is what I get:

Smith, John Reilly, James Sykes, Matt

What I want is this:

Smith, John
Reilly, James
Sykes, Matt

The names come from user input by the way.

This is my code to print the list:
Expand|Select|Wrap|Line Numbers
  1. visitors.sort()
  2. print ' '.join(visitors)
Oct 31 '10 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 624
Look up traversing a list.
Oct 31 '10 #2

Expert Mod 2.5K+
P: 2,851
Or you can use:
Expand|Select|Wrap|Line Numbers
  1. print "\n".join(visitors)
Nov 1 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.