Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 9 Online
OpenStudy (anonymous):

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".

OpenStudy (anonymous):

sorry not week but weak

OpenStudy (anonymous):

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

OpenStudy (anonymous):

if a leter is insert in the dathe of birth then the program crashes and i whant it to simply ask agend

OpenStudy (e.mccormick):

Then you need to learn about how to do inpiut validation. That is not always a simple task.

OpenStudy (e.mccormick):

Here, this goes over it: http://cis1.towson.edu/~cssecinj/modules/cs1/input-validation-cs1-python/

OpenStudy (rsmith6559):

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 )

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!