We're going way back for this one. Today's problem is creating a digital typewritter. When the program is run it will allow the user to enter text. When the user hits enter that line will be saved to a text file. The program runs until the following combination occurs: blank line > enter > "." > enter.
Bonus Round
- Open the file after the user is done inputting text (after the blank line > enter > "." > enter has occurred)
- Limit the number of characters per line to 72
Comments:
Pegleg - 10 years, 8 months ago
Good moring everyone, Python 3.4
reply permalink
Anonymous - 10 years, 8 months ago
blank_line should be checked and reset at the end of your loop, else the exit combination doesn't have to happen consecutively
reply permalink
Hueho - 10 years, 8 months ago
Dunno if the CLI open is avaiable anywhere outside Mac OS, but here we go:
Also adding a byte limit in gets is not working for some reason. :(
reply permalink
Walker Crouse - 10 years, 8 months ago
It varies on different platforms, for instance Ubuntu and it's flavors use "see <file>".
reply permalink
Walker Crouse - 10 years, 8 months ago
Short but sweet Py
Output
reply permalink