-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpmax.py
29 lines (28 loc) · 785 Bytes
/
pmax.py
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
def max1(*args):
""" get max of any itrable
--> Facts:
if you pass all arguments like lists or tuple or set so function will compare only first
list[0] value and give max.
example:-
[1, 3, 2] and [2, 1, 4] so answer will be [2, 1, 4] """
if len(args) > 1:
imax = args[0]
i = 0
while i < len(args):
if imax < args[i]:
imax = args[i]
i += 1
return imax
if len(args) == 1 and type(args) == list or tuple or set:
i = 0
a = list(args[0])
imax = a[0]
while i < len(a):
if imax < a[i]:
imax = a[i]
i += 1
return imax
# example
# x = [2, 5, 2, -1, 6]
# a = min1(x)
# print(a)