Python Forum

Full Version: adding elements to a list that are more than a specific number
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do I add elements from a list to another list that are more than a specific number?

I've tried this:
list1=[2, 5, 3]
list2=[]
if number in list1 > 3:
list2.append(number)

Why does this not work, and how can I change it?
To iterate over items use for-loop and then use if-comparison to check value.
(Mar-19-2020, 03:35 PM)perfringo Wrote: [ -> ]To iterate over items use for-loop and then use if-comparison to check value.
thank you