"Katt" <the_only_kat...@verizon.net> wrote
date = "cyear_11_05"
date2 = date.split("_")
check_year = date2[0]
if check_year == "cyear":
year = localtime().tm_year
else:
year = int(date2[0])
print year
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".
When debugging this kind of thing insert some print statements
to check what date2 and check_year really look like. Or try using
the >>> prompt to experiment until you are happy with the behaviour
of the function with differernt sample data.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor