[NooB] Using Escape Sesquences with Strings...
administrata
administrata at hotmail.com
Fri Feb 11 17:21:25 EST 2005
bruno modulix <onurb at xiludom.gro> wrote in message news:<420cbe89$0$526$636a15ce at news.free.fr>...
> administrata wrote:
> > Hello! :)
> > I've reading 'Python Programmin for the Absolute beginner'.
> > I got questions which is...
> >
> > print "\t - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
> >
> > rock = """
> > Igneous Sedimentary Metamorphic
> >
> > Lava Grains Marble
> > Ramdom crystals Layer Bands
> > Granite Salt Schist
> > Intrusive Weathering Heat + Pressure
> > Deposition Change"""
> > print \trock
> >
> > print "\t - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
> >
> > error occurs!
> >
> > I don't know how to \t The variable.
>
> see Daniel's answer for the why.
> Now for the how, I guess you want a tab on each line so you have two
> solutions :
> 1/ putting the tabs in the string:
> rock = """
> \tIgneous Sedimentary Metamorphic
>
> \tLava Grains Marble
> \tRamdom crystals Layer Bands
> \tGranite Salt Schist
> \tIntrusive Weathering Heat + Pressure
> \t Deposition Change"""
>
> print rock
>
> 2/ adding the tabs before printing:
> rock = """
> Igneous Sedimentary Metamorphic
>
> Lava Grains Marble
> Ramdom crystals Layer Bands
> Granite Salt Schist
> Intrusive Weathering Heat + Pressure
> Deposition Change"""
>
>
> for line in rock.split("\n"):
> print "\t%s" % line
>
> HTH,
thx 4 your helpful msg.
I'll input 1 instead of 2 which is a bit complicated for me.
More information about the Python-list
mailing list