This page looks best with JavaScript enabled

How not to get user inputs!

 ·  ☕ 1 min read

Posted to r/learnpython

The challenge

The challenge was to ask the user for the start year, month and day (three separate requests) and the same for the end date in the least number of lines possible. Pretty sure this breaks about every rule from the Zen of Python but here goes!

1
2
3
import datetime
j = lambda y: datetime.datetime(*list(map(lambda x: int(input(x)),[f'{y} {x}:' for x in ['Year','Month','Day']])))
start, end = j('Start'), j('End')
Share on