[Tutor] Problem with variables

Jeremy Jones zanesdad at bellsouth.net
Wed Feb 16 15:45:27 CET 2005


. Sm0kin'_Bull wrote:

>
>  wrote this, It's a bit lame though
>
> I = "Allen"
> me = "Allen"
> my = "Allen's"
>
> print \
> """
> %s woke up early in the morning. But, it was unusal by %s. %s pillow
> was with %s. %s didn't want to wake up But, %s tried my best and woke up.
> it was so amazing!""" % (I,me,my,me,I,I)
>
> raw_input("\n\\t\t\t- The End -")
>
> But it looks like this...
>
> Allen woke up early in the morning. But, it was unusal by Allen.
> Allen's pillow
> was with Allen. Allen didn't want to wake up But, Allen tried my best 
> and woke up.
> it was so amazing
>
>                             - The End -
>
>the problem is about lining
>  
>
>I want it to print like this...
>  
>
>Allen woke up early in the morning. But, it was unusal by Allen.
>Allen's pillow was with Allen. Allen didn't want to wake up But, Allen
>tried my best and woke up. it was so amazing
>
>
>

This is what I got:

########################
In [45]: I = "Allen"

In [46]: me = "Allen"

In [47]: my = "Allen's"

In [48]:

In [48]: print \
   ....: """
   ....: %s woke up early in the morning. But, it was unusal by %s. %s 
pillow
   ....: was with %s. %s didn't want to wake up But, %s tried my best 
and woke up.
   ....: it was so amazing!""" % (I,me,my,me,I,I)

Allen woke up early in the morning. But, it was unusal by Allen. Allen's 
pillow
was with Allen. Allen didn't want to wake up But, Allen tried my best 
and woke up.
it was so amazing!
########################

It looks like it should.  If you want it to show up exactly like posted 
at the end, you need something more like this:

########################
In [50]: print \
   ....: """
   ....: %s woke up early in the morning. But, it was unusal by %s.
   ....: %s pillow was with %s. %s didn't want to wake up But, %s
   ....: tried my best and woke up. it was so amazing!""" % (I,me,my,me,I,I)

Allen woke up early in the morning. But, it was unusal by Allen.
Allen's pillow was with Allen. Allen didn't want to wake up But, Allen
tried my best and woke up. it was so amazing!
###########################

Jeremy Jones


> ** 
>
> ------------------------------------------------------------------------
> FREE pop-up blocking with the new MSN Toolbar MSN Toolbar 
> <http://g.msn.com/8HMAEN/2755??PS=47575> Get it now!
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>  
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050216/bff6d70b/attachment.html


More information about the Tutor mailing list