Yozuru

April 26th, 2014, 08:36 PM

Hello good people,

I am working on a practice problem that involves list comprehension and range.

So I have a list called 'sampleList', and I have to write a list comprehension that would return the sublist of 'sampleList' consisting of numbers that belong in interval [-11, 5]

This is currently what I have so far:

subsampleList = [x for x in sampleList if range(-11, 6)]

On another problem, I need to make a list of hexadecimals of entries in sampleList that returns non-negative numbers.

[hex(x)) for x if sampleList >0]

I am as of now lost with list comprehension and any help would be greatly appreciated.

I am working on a practice problem that involves list comprehension and range.

So I have a list called 'sampleList', and I have to write a list comprehension that would return the sublist of 'sampleList' consisting of numbers that belong in interval [-11, 5]

This is currently what I have so far:

subsampleList = [x for x in sampleList if range(-11, 6)]

On another problem, I need to make a list of hexadecimals of entries in sampleList that returns non-negative numbers.

[hex(x)) for x if sampleList >0]

I am as of now lost with list comprehension and any help would be greatly appreciated.