A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 4 years ago
Is there a more elegant way to validate the month input for this Zeller's Algorithm program? I've done the exercise (Opt. 1 in week 2 for #MOOC) and it works, but I wonder if there's a more elegant way to validate the input. It should check that you've entered a real month. I did:
while month != 'march' and month != 'april' etc.
anonymous
 4 years ago
Is there a more elegant way to validate the month input for this Zeller's Algorithm program? I've done the exercise (Opt. 1 in week 2 for #MOOC) and it works, but I wonder if there's a more elegant way to validate the input. It should check that you've entered a real month. I did: while month != 'march' and month != 'april' etc.

This Question is Closed

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Put all valid months in a list and check if the input exists in the list (or is member of the list)

pdpinch
 4 years ago
Best ResponseYou've already chosen the best response.1This might save you some typing: import calendar while month not in calendar.month_name: # ask for another month
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.