Hi @ all, I just started with outdated. I was wondering how to catch an out of range error for DD > 31 or MM > 12. I thought first splitting the user input into variables like a, b, c = input.split('/') like we're told in the hints, then converting to integers by using the modulus operator, e.g.
a, b, c = int(a) % 12, int(b) % 31, int(c). Is that alright or am I obliged to raise an exception?
I love learning math (*to some extent*) and CS theory; good literature, and the technology that provides me with all kinds of resources for those three: the web.
It seems that dev.to has an issue with notifications for comments on original content, I haven't seen yours until I have just encountered it, I really apologize for the inconvenience of the delay.
You've probably already had an answer to your question by now, but I still wanted to reply.
I don't think there is any need to convert the variables to integers while splitting. A simple conditional was enough in my solution to check if the values were not out of range, and since the output was going to be a string, you could just
convert them to integers for the conditional, with something like if 0 < int(day) < 32 and 0 < int(month) < 13. I don't think it would require raising an exception here, we could just raise a ValueError for the input itself if it was faulty.
Again, I apologize for the long-delayed response, hope you're doing well.
Hi @ all, I just started with outdated. I was wondering how to catch an out of range error for DD > 31 or MM > 12. I thought first splitting the user input into variables like a, b, c = input.split('/') like we're told in the hints, then converting to integers by using the modulus operator, e.g.
a, b, c = int(a) % 12, int(b) % 31, int(c). Is that alright or am I obliged to raise an exception?
Hello Gebhard,
It seems that dev.to has an issue with notifications for comments on original content, I haven't seen yours until I have just encountered it, I really apologize for the inconvenience of the delay.
You've probably already had an answer to your question by now, but I still wanted to reply.
I don't think there is any need to convert the variables to integers while splitting. A simple conditional was enough in my solution to check if the values were not out of range, and since the output was going to be a string, you could just
convert them to integers for the conditional, with something like
if 0 < int(day) < 32 and 0 < int(month) < 13
. I don't think it would require raising an exception here, we could just raise aValueError
for the input itself if it was faulty.Again, I apologize for the long-delayed response, hope you're doing well.
Hi Eda, yes I know that, happens to me all the time (overlooking messages). Don't worry about it, hope you're doing well, too