formatting string inside a list

This is the place for queries that don't fit in any of the other categories.

formatting string inside a list

Postby wazoo » Sun Apr 06, 2014 6:56 pm

i have a list of strings that i want to format, the list looks something like this:

Code: Select all
a = ['i am coming home' , 'something is better than nothing', 'whats up?']


is there any way to write to the list elemt i.e. string like this:

Code: Select all
a = ['i am coming home', 'something is better
      than nothing', 'whats up?]


this gives an error...

then i tried this

Code: Select all
a = ['i am coming home', 'something is better ...
      than nothing', 'whats up?]


this also gives an error.
so is there any way to write a string in two lines in a list??
Last edited by stranac on Sun Apr 06, 2014 7:14 pm, edited 1 time in total.
Reason: Added code tags. Locked.
wazoo
 
Posts: 2
Joined: Sun Apr 06, 2014 6:48 pm

Re: formatting string inside a list

Postby stranac » Sun Apr 06, 2014 7:16 pm

Yep, you do it like this:
Code: Select all
a = ['i am coming home' , 'something is better '
     'than nothing', 'whats up?']


Also, this is not what people usually mean when they talk about formatting a string...
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1246
Joined: Thu Feb 07, 2013 3:42 pm

Re: formatting string inside a list

Postby wazoo » Sun Apr 06, 2014 7:28 pm

Got it thanks.
I guess 'spacing strings inside a list' would have been the right word. I'm new at this thats why i used formatting
wazoo
 
Posts: 2
Joined: Sun Apr 06, 2014 6:48 pm


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 4 guests