Light Mode
Dark Mode
Remove all before

hi, any suggestions to display the entire list when not finding the first digit of the new list.

from typing import Iterable
    def remove_all_before(items: list, border: int) -> Iterable:
        z=[]
        y=[]
        v=[]
        for i in range(len(items)):
            if items[i] >= border:
                y.append(items[i])   #<==new list
            else:
                z.append(items[i])   #<copy orignal list

    if y != v :
        return y
    else:
        return z
if __name__ == '__main__':
    print("Example:")
    print(list(remove_all_before([1, 2, 3, 4, 5], 3)))

    # These "asserts" are used for self-checking and not for an auto-testing
    assert list(remove_all_before([1, 2, 3, 4, 5], 3)) == [3, 4, 5]
    assert list(remove_all_before([1, 1, 2, 2, 3, 3], 2)) == [2, 2, 3, 3]
    assert list(remove_all_before([1, 1, 2, 4, 2, 3, 4], 2)) == [2, 4, 2, 3, 4]
    assert list(remove_all_before([1, 1, 5, 6, 7], 2)) == [1, 1, 5, 6, 7]  #<--------------<----------<my error
    assert list(remove_all_before([], 0)) == []
    assert list(remove_all_before([7, 7, 7, 7, 7, 7, 7, 7, 7], 7)) == [7, 7, 7, 7, 7, 7, 7, 7, 7]
  • count
  • len
  • list
  • python
  • range
  • remove
Created: March 30, 2020, 12:06 p.m.
Updated: March 30, 2020, 6:11 p.m.
0
8
User avatar
Mateu52