Python Forum
More List Stuff - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: More List Stuff (/thread-8846.html)



More List Stuff - Zman350x - Mar-10-2018

How would I do this?
data = [1,3,6,7,10]
value = 5

Lower = ["""List of Numbers in data list lower than value(5)"""]
Higher = ["""List of Numbers in data list higher than value(5)"""]
Equal = ["""List of Numbers in data list equal to value(5)"""]



RE: More List Stuff - Larz60+ - Mar-10-2018

What would be your guess?
ask yourself:
  • How do I access each element of the list?
  • Is that element < 5
  • or is that element > 5
  • or is that element == 5



RE: More List Stuff - DeaD_EyE - Mar-10-2018


  1. You need operators: < > ==
  2. You need to iterate over the list and do the comparison with the operators inside the loop.
  3. If the condition is True, add the element to a new list



RE: More List Stuff - Zman350x - Mar-11-2018

sorry for not saying this, I fixed the problem right after posting