I have completed the problema set 0 but i consider it week. because it crashes when i insert a leter in the dathe of birth while i want it simply to restart the question if a leter is insert in the date "spot".
sorry not week but weak
my program is: print ("enter your dathe of birth by the folowing order") day = 0 while day < 1 or 31< day day = int(raw_input("day= ")) month = 0 while month < 1 or 12 < month month = int(raw_input("month= ")) year = 0 while year < 1900 or 2015 < year year = int(raw_input("year= ")) lastname = raw_input("enter your last name") print ("last name= " + lastname + " dathe of birth= " + date + "-" + month + "-" + year
if a leter is insert in the dathe of birth then the program crashes and i whant it to simply ask agend
Then you need to learn about how to do inpiut validation. That is not always a simple task.
Here, this goes over it: http://cis1.towson.edu/~cssecinj/modules/cs1/input-validation-cs1-python/
The int() function gets testy when given a character. raw_input() returns strings. You can check to see if the string is digits with the isdigit() method: dayString = raw_input("day= ") if( dayString.isdigit() ): day = int( dayString )
Join our real-time social learning platform and learn together with your friends!