forked from xt0fer/PythonLab1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistsuse.py
More file actions
35 lines (25 loc) · 733 Bytes
/
listsuse.py
File metadata and controls
35 lines (25 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from numbers import Number
from typing import Any, List
def largest_in_list(list: List[Number]) -> Number:
return max(list)
def reverse_list(list: List[Any]) -> List[Any]:
result = []
for i in range(len(list)):
result.append(list[len(list) - i - 1])
return result
def contains(element: Any, list: List[Any]) -> bool:
for item in list:
if item == element:
return True
return False
def every_other_list(list: List[Any]) -> List[Any]:
result = []
for i in range(len(list)):
if i % 2 == 1:
result.append(list[i])
return result
def total(list: List[Number]) -> Number:
sum = 0
for element in list:
sum += element
return sum