On 2014-02-18 10:30, kjaku...@gmail.com wrote:
> So let's say I have a file and it looks like this:
> Title 1: item 
> Title 2: item 
> etc
> 
> Is it possible to use a dictionary for something like the input
> above? Because I want to be able to use the input above to delete
> the "Title 1" and "Title 2" but still show the items (on separate
> lines). Basically I want it to just show: item item 
> etc..
> 
> What I've got is 
> dict(item.split(":") for item in cInfo.split(" "))
> 
> Where cInfo is a function that extracts the first 5 lines of a file

It sounds like all you need is some basic string functions, not a
dictionary:

  for line in file('input.txt'):
    title, _, item = line.partition(':')
    print(item.strip())

-tkc



-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to