[Tutor] Change a text string from a list and change it into an integer number.(WinXP/py2.6.2/Beginner)

Wayne Werner waynejwerner at gmail.com
Fri Nov 6 04:34:31 CET 2009


On Thu, Nov 5, 2009 at 8:44 PM, Katt <the_only_katala at verizon.net> wrote:

> <snip>
> Currently the above code does not work unless I change the "if" statement
> to say:
> "if check_year == "c".
>
> Did I do the slice incorrectly?  I thought that when you take the first
> location (0) of a list then it would take the "cyear" in stead of just the
> "c".
>
>
It works correctly for me. Try modifying your code:

date = "cyear_11_05"
date2 = date.split("_")
check_year = date2[0]
print check_year

what does that do for you?
-Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091105/cbc14542/attachment.htm>


More information about the Tutor mailing list