Aug-16-2018, 01:18 AM
(This post was last modified: Aug-16-2018, 11:32 AM by Drone4four.)
This helps, @knackwurstbagel. My loop in its current form doesn’t actually do anything, as you’ve explained. But by modifying it slightly, also as you’ve suggested, it shows how the split function works. Here is the new output with your suggested modification:
I see now. The lines in the text file are split according to white space, not individual characters.
@Larz60+: Your code is elegant and far superior than mine. You mentioned buffering. I don’t really understand what you mean by file buffering and file pointers but it may have to do with the Jupyter Notebook tool that I’m doing this exercise with. You’ve done a terrific job re-writing my script on your own terms, but if I wanted to retain my somewhat novice approach while keeping my general awkward syntax, how would you modify my script to avoid making the mistake I made with the file-pointer buffer issue?
Quote:['Welcome', 'to', 'your', 'First', 'Exam', 'Recruit.']
['Only', 'the', 'best', 'recruits', 'can', 'become', 'agents.']
['Do', 'you', 'have', 'what', 'it', 'takes?']
['We', 'will', 'test', 'your', 'knowledge', 'with', 'this', 'field', 'readiness', 'exam.']
['It', 'should', 'be', 'pretty', 'simple,', 'since', 'you', 'only', 'know', 'the', 'basics', 'so', 'far.']
["Let's", 'get', 'started.']
['Best', 'of', 'luck', 'recruit.']
It should be pretty simple, since you only know the basics so far.
I see now. The lines in the text file are split according to white space, not individual characters.
@Larz60+: Your code is elegant and far superior than mine. You mentioned buffering. I don’t really understand what you mean by file buffering and file pointers but it may have to do with the Jupyter Notebook tool that I’m doing this exercise with. You’ve done a terrific job re-writing my script on your own terms, but if I wanted to retain my somewhat novice approach while keeping my general awkward syntax, how would you modify my script to avoid making the mistake I made with the file-pointer buffer issue?