Python One-Liners: Higher or Lower
Here is an example of the game "higher or lower" written in a single line. I've used a variety of tricks to make this work in a single line such as:
- globals().setattr to let me set variables inside a lambda function
- (globals().setattr("guess",x) or globals ()["guess"]) to use the := operator in python 3.7, the := operator only being introduced in python 3.8 which repl.it has yet to upgrade to
- for i in iter(int, 1) instead of a while loop which would require more than one line
And some others. If you'd like, share some of your other one-line programs because I'm interested in them at the moment.