Exercise 48: Advanced User Input
In past games you handled the user's input by simply expecting set strings. If the user typed "run", and exactly "run", then the game worked. If they typed in similar phrases like "run fast" it would fail. What we need is a device that lets users type phrases in various ways and then convert that into something the computer understands. For example, we'd like to have all of these phrases work the same:
- open door
- open the door
- go THROUGH the door
- punch bear
- Punch The Bear in the FACE
Ready To Learn To Code?
If you enjoyed the sample so far, then you can continue learning by Buying Learn Python 3 The Hard Way for 29.99. You'll receive all 52 exercises in PDF and HTML formats, plus 12 hours of 1080p teaching you each exercise. This course has helped 12 million people learn to code since 2010, so it can help you too. If you want to see more samples then try the Appendix A: Command Line Crash Course. If you already purchased this book then you can download the videos at your account page or view the paid HTML version.
Need To Learn For Free?
My Learn Ruby The Hard Way is still free to read for anyone who needs to learn to code. Ruby is a perfectly fine alternative to Python, and works just as well as a first language. If you can't afford Learn Python The Hard Way then read Learn Ruby The Hard Way for free.