Skip to content

Instantly share code, notes, and snippets.

@jasonsperske
Created November 16, 2012 18:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonsperske/4089505 to your computer and use it in GitHub Desktop.
Save jasonsperske/4089505 to your computer and use it in GitHub Desktop.
list_of_lists=[]
category=0
list_of_lists.append([])
f = open("list.txt",'r')
for line in f.readlines():
item = line.strip('\n') # no white spaces in the list
if len(item) > 0:
#add to current category
list_of_lists[category].append(item)
else:
#add new category
list_of_lists.append([])
category = category + 1
f.close()
print(list_of_lists)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment