[Tutor] Removing characters in a string using format()

Ryan Porter websterhamster at felton4h.net
Fri Jul 22 01:10:37 CEST 2011


Thanks for help, James! It works perfectly.

Ryan

On 7/21/2011 11:13 AM, James Reynolds wrote:
> Since you're using python 3, you can just use a star to unpack the list
>
> like so:
>
> >>> print(*x)
> a b
> >>> print(*x, sep = ', ')
> a, b
>
> You can use sep to change the separator if you want the commas still.
>
>
> On Thu, Jul 21, 2011 at 1:53 PM, Ryan Porter 
> <websterhamster at felton4h.net <mailto:websterhamster at felton4h.net>> wrote:
>
>     Hi there,
>
>     In one part of a program I'm writing, I want a list to be printed
>     to the string. Here's my code:
>
>     # Begin snippet
>     listString = input('Please enter a single item: >').strip();
>
>     /        print();
>            itemList.append(listString);
>     /
>
>     /...
>     /
>
>     /print('And here it is in alphabetical order:', itemList)
>     # End Snippet
>     /
>
>     However, when I print the list, I get something like this:
>     ['Python', 'best', 'ever', 'is', 'language', 'programming', 'the']
>     with brackets. Is there a way to use format() to remove the
>     brackets before the list is printed?
>
>     Thanks for the help!
>     //
>
>     _______________________________________________
>     Tutor maillist  - Tutor at python.org <mailto:Tutor at python.org>
>     To unsubscribe or change subscription options:
>     http://mail.python.org/mailman/listinfo/tutor
>
>


-- 

Ryan Porter Web Design & Piano Lessons

/"For my soul delighteth in the song of the heart; yea, the song of the 
righteous is a prayer unto me, and it shall be answered with a blessing 
upon their heads." ~D&C 25:12/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110721/d16bc4e7/attachment.html>


More information about the Tutor mailing list