Rajanikanth Jammalamadaka wrote:
[5, 6, 7, 8, 9]
>
Why doesn't this work?
>
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
it works exactly as specified:
Help on class dropwhile in module itertools:
class dropwhile(__bui ltin__.object)
| dropwhile(predi cate, iterable) --dropwhile object
|
| Drop items from the iterable while predicate(item) is true.
| Afterwards, return every element until the iterable is exhausted.
False
maybe you meant to use itertools.ifilt er?
Help on class ifilter in module itertools:
class ifilter(__built in__.object)
| ifilter(functio n or None, sequence) --ifilter object
|
| Return those items of sequence for which function(item) is true.
| If function is None, return the items that are true.
[0, 1, 2, 3, 4]
[3, 4]
</F>
>>>list(itertoo ls.dropwhile(la mbda x: x<5,range(10)) )
>
Why doesn't this work?
>
>>>list(itertoo ls.dropwhile(la mbda x: 2<x<5,range(10) ))
>>help(itertool s.dropwhile)
class dropwhile(__bui ltin__.object)
| dropwhile(predi cate, iterable) --dropwhile object
|
| Drop items from the iterable while predicate(item) is true.
| Afterwards, return every element until the iterable is exhausted.
>>2<0<5
maybe you meant to use itertools.ifilt er?
>>help(itertool s.ifilter)
class ifilter(__built in__.object)
| ifilter(functio n or None, sequence) --ifilter object
|
| Return those items of sequence for which function(item) is true.
| If function is None, return the items that are true.
>>list(itertool s.ifilter(lambd a x: x<5,range(10)) )
>>list(itertool s.ifilter(lambd a x: 2<x<5,range(10) ))
</F>