Skip to content

Instantly share code, notes, and snippets.

@AnthonyNixon
Created February 2, 2017 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnthonyNixon/bc8201256642ae5f09de4ebf43cdb5e3 to your computer and use it in GitHub Desktop.
Save AnthonyNixon/bc8201256642ae5f09de4ebf43cdb5e3 to your computer and use it in GitHub Desktop.
#!/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