# ----------- # User Instructions # # Modify the valid_day() function to verify # whether the string a user enters is a valid # day. The valid_day() function takes as # input a String, and returns either a valid # Int or None. If the passed in String is # not a valid day, return None. # If it is a valid day, then return # the day as an Int, not a String. Don't # worry about months of different length. # Assume a day is valid if it is a number # between 1 and 31. # Be careful, the input can be any string # at all, you don't have any guarantees # that the user will input a sensible # day. # def valid_day(day): if day.isdigit() and int(day) in range(1,32): return int(day) return None # valid_day('0') => None # valid_day('1') => 1 # valid_day('15') => 15 # valid_day('500') => None
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question