Re: unorderable types: list() > int()

2017-10-13 Thread Andrew Z
The answer is: The dict returns list - my mistake obviously. I think list.pop(0) is better for sanity than list[0]: Pos= [k,v for ...].pop(0) On Oct 13, 2017 00:23, "Andrew Z" wrote: > Hello, > pos = {"CLown":10,"BArbie":20} > I want to return integer (10) for the

Re: unorderable types: list() > int()

2017-10-13 Thread Peter Otten
Andrew Z wrote: > Hello, > pos = {"CLown":10,"BArbie":20} > I want to return integer (10) for the keyword that starts with "CL" > > > cl_ = [v for k, v in pos.items() if k.startswith('CL')] > cl_pos = cl_[0] > if cl_pos > 0: > >blah.. > > > There are 2 issues with the above: > a. ugly -

Re: unorderable types: list() > int()

2017-10-12 Thread Steve D'Aprano
On Fri, 13 Oct 2017 03:23 pm, Andrew Z wrote: > Hello, > pos = {"CLown":10,"BArbie":20} > I want to return integer (10) for the keyword that starts with "CL" > > > cl_ = [v for k, v in pos.items() if k.startswith('CL')] > cl_pos = cl_[0] > if cl_pos > 0: > >blah.. > > > There are 2

unorderable types: list() > int()

2017-10-12 Thread Andrew Z
Hello, pos = {"CLown":10,"BArbie":20} I want to return integer (10) for the keyword that starts with "CL" cl_ = [v for k, v in pos.items() if k.startswith('CL')] cl_pos = cl_[0] if cl_pos > 0: blah.. There are 2 issues with the above: a. ugly - cl_pos = cl_ [0] . I was thinking something