forked from tdwojak/Python2017
34 lines
769 B
Python
34 lines
769 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Zad 2. Napisz funkcję even_elements zwracającą listę,
|
|
która zawiera tylko elementy z list o parzystych indeksach.
|
|
"""
|
|
def even_elements(b):
|
|
lista=(b[::2])
|
|
"""listaa=[]
|
|
|
|
for i in range(3):
|
|
for k in range (1):
|
|
#print(inputs[i][0][::2])
|
|
listaa.append(lista[i][0][::2])"""
|
|
#lista(str(lista).strip('[]'))
|
|
return lista
|
|
|
|
|
|
|
|
def tests(f):
|
|
inputs = [[[1, 2, 3, 4, 5, 6]], [[]], [[41]]]
|
|
outputs = [[1, 3, 5], [], [41]]
|
|
|
|
for input, output in zip(inputs, outputs):
|
|
if f(*input) != output:
|
|
return "ERROR: {}!={}".format(f(*input), output)
|
|
break
|
|
return "TESTS PASSED"
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(tests(even_elements))
|