나는 이렇게 학습한다/Algorithm & SQL

1110. No oddities here

daco2020 2022. 11. 10. 22:39
반응형

Write a small function that returns the values of an array that are not odd.

All values in the array will be integers. Return the good values in the order they are given.



Solution:

class NoOdd:
    def __init__(self):
        self.__values: list[int] = []

    def run(self, values: list[int]) -> list[int]:
        self._set_values(values)
        self._remove_odd()
        return self._get_values()

    def _set_values(self, values) -> None:
        self.__values = values

    def _remove_odd(self) -> None:
        self._set_values([value for value in self.__values if value % 2 == 0])

    def _get_values(self) -> list[int]:
        return self.__values


no_odds = NoOdd().run


반응형