Created
February 2, 2017 19:22
-
-
Save Niximacco/bc8201256642ae5f09de4ebf43cdb5e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import re | |
with open('script', 'r') as scriptfile: | |
script=scriptfile.read() | |
bottles = [] | |
currentString = "" | |
for c in script: | |
if len(currentString) == 0: | |
if not c == ' ': | |
currentString = currentString + c | |
elif len(currentString) < 18: | |
currentString = currentString + c | |
elif len(currentString) >= 18 and c == ' ': | |
bottles.append(currentString) | |
currentString = "" | |
else: | |
stringParts = currentString.split(' ') | |
newStringParts = [] | |
for i in range(len(stringParts)-1): | |
newStringParts.append(stringParts[i]) | |
currentString = stringParts[len(stringParts) - 1] | |
currentString = currentString + c | |
newString = " ".join(newStringParts) | |
bottles.append(newString) | |
print bottles | |
print len(bottles) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment