Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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