[Tutor] string thing

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri Nov 21 14:04:39 EST 2003


> 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


Hi Larry,

There's also a small section on the official Python tutorial that talks
about using these string formatting tools.  You can find out more by
looking here:

    http://www.python.org/doc/tut/node9.html


If you have more questions, please feel free to ask on Python-Tutor!




More information about the Tutor mailing list