1
0
forked from tdwojak/Python2017
Python2017/labs02/task01.py
2017-11-19 15:42:56 +01:00

57 lines
1.1 KiB
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.
== identyczne
!= rozne
and
or (malymi literami)
"""
lista = [5, 7, 9, 0, 10]
def even_elements(lista):
for i in lista:
id = lista.index()
if id %2==0:
print('parzyste indeksy', even_elements(id))
l = [99, 44, 33]
print(l.index(44))
def find_element_in_list(element, list_element):
try:
index_element = list_element.index(element)
return index_element
except ValueError:
return None
lista = [5, 7, 9, 0, 10]
id = lista.index("5")
print("lista",[id])
testlist = [1,2,3,5,3,1,2,1,6]
for id, value in enumerate(testlist):
if id == 3:
print(testlist[id])
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))