[Tutor] string thing

Gregor Lingl glingl at aon.at
Fri Nov 21 00:55:20 EST 2003



Larry schrieb:

>I am trying to get python to print  
>
>a = ( val, val)
>print a
>
>and the output is:
>('0', '0')
>
>I want the output to be:
>
>(0, 0)
>
>How do I get rid of the ' '
>gizmos.   (:
>
Hi Larry,
There is more than one way to achieve this ...

e.g. turn val into an integer:
 >>> val = '0'
 >>> ival = int(val)
 >>> a = (ival,ival)
 >>> print a
(0, 0)
 >>>

or use Python's string-formatting:
 >>> a=(val,val)
 >>> print "(%s, %s)" % a
(0, 0)
 >>>

More about this here:  
http://www.python.org/doc/current/lib/typesseq-strings.html

Regards, Gregor


>
>Thanks
>
>
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>  
>




More information about the Tutor mailing list