Firstly 'input' is a reserved word in python, it's used to get input from the user, (rather like raw_input!). So that's why this line of code fails to do anything:
input = raw_input("Type Date dd/mm/year: ")
Change your variable 'input' to something like 'userInput' or just anything that isn't a reserved word and you will get your prompt!
Secondly...No I don't think that strptime will work used like that! if your users enter anything other than yy-mm-dd, it will bomb out with an error!
But if you use a try: except: block inside a loop, you should be able to get the user to repeatedly enter the date until the format is correct!
Check this out:
import datetime
def ObtainDate():
isValid=False
while not isValid:
userIn = raw_input("Type Date dd/mm/yy: ")
try: # strptime throws an exception if the input doesn't match the pattern
d = datetime.datetime.strptime(userIn, "%d/%m/%y")
isValid=True
except:
print "Doh, try again!\n"
return d
#test the function
print ObtainDate()
I've not done any exception handling code for a while, but there should be a way of outputting to the user the reason that the exception occurred.
I'll leave that up to you to look up!
Cheers for now,
Jas