Please reply to the tutor list, not just to me. We all learn and many of us can help.

Brummert_Brandon wrote:
This is what I have so far.  I am still confused by the string.split  setup.  
Thank you.


# dateCheck.py
# A program that accepts a date in the form month/day/year and outputs whether 
date is valid.
# Brandon Brummert, October 20, 2008

import string
def isLeapYear(leap):
    if 0 == year % 400:
        return True
    elif 0 == year % 100:
        return False
    elif 0 == year % 4:
        return True
    else:
        return False

def daysInMonth (date):
    if 1 or 3 or 5 or 7 or 8 or 10 or 12:
        return 31
    elif 4 or 6 or 9 or 11:
        return 30
    elif 2:
        return leap
def main():
    currentdate= input ("What is the date (mm/dd/yyyy)?:")
    month, date, year= string.split(currentdate)
    print month/date/year
main()



Thank you. That is half of the input I'm seeking. The other half is: what happens when you run the program?
I'd expect you see a prompt:

What is the date (mm/dd/yyyy)?:

What do you enter at this prompt?

What happens next? You should see an exception (error). What is it? Why do you think it means and why did it happen?

Read the documentation for input().

As an aside - your program shows very little understanding of Python. Have you written other programs that ran the way you expected, or is this your first try?

Since it is homework we don't write the program for you. I'm trying to nudge you in the right direction, and would appreciate all you can give it.

Did you read the documentation for split?

month/date/year

is an expression. What does the / mean in an expression?

At the Python interpreter prompt >>> enter

if 1 or 3 or 5 or 7 or 8 or 10 or 12:
 print True

What happens? Why? Then try

if 1:
 print True

You are trying to compare date to numbers yet date does not appear in the if statement!

I have mentioned lists twice yet you have not said anything about them. Do you know what a list is and how it can be used?

--
Bob Gailer
Chapel Hill NC 919-636-4239

When we take the time to be aware of our feelings and needs we have more satisfying interatctions with others.

Nonviolent Communication provides tools for this awareness.

As a coach and trainer I can assist you in learning this process.

What is YOUR biggest relationship challenge?

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to