[Tutor] How to print a %-sign

Kent Johnson kent37 at tds.net
Sun Oct 21 01:18:37 CEST 2007


Leon Hasbeck wrote:
> Hi,
> 
> I would like to give out a formatted string that includes a percent sign,  
> that
> is not used as formatting sign.Example:
> 
> print "Your chance to win is %4.2f %" %p

Just double the %:
print "Your chance to win is %4.2f %%" %p

Kent

> 
> This doesn't work, because the last %-sign is interpreted as formatting  
> sign and
> thus leads to an error message. I tried \x25 instead, but that doesn't  
> work as well
> (same error message).
> 
> Can someone help me?
> 
> Leon
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



More information about the Tutor mailing list