+ 3
WHY IS THIS WRONG?
def my_min(*x): for i in x: for a in x: if i < a: continue elif i >= a: return my_min(x[a:]) return i print(my_min(8, 13, 4, 42, 120, 7))
15 Respostas
+ 7
here is a solution with a simple for loop that is working:
def get_min(nums_tup):
min_ = a[0]
for num in a:
if num < min_:
min_ = num
return min_
print(get_min((18, 4,32,10,1, -1,55,100,11)))
+ 4
FF9900 ,
can you please enlighten me why
> ox = 2^32 is used? the expression results in: *34*
and i also would like to ask why the values in the tuple
> a =(184, 41,320,100,99, 1111,55,100,110)
is giving a result of *34* as the minimum element, even is this elemrnt is not existing?
+ 4
FF9900 ,
despite of the correction you made in the code, the error remains if the numbers in the tuple are greater than 2**32.
+ 1
Ahhh yes, much simpler, many thanks :)
+ 1
👍
0
Yep, in the tuple. I figured out whts wrojg though i think
0
I know that a min() function exists, i just wanted to sus out what that actually was—->
def my_min(*x):
for i in x:
for a in x:
if i < a:
continue
elif i >= a:
i = a
continue
return i
print(my_min(8, 13, 4, 42, 120, 7))
0
This works
0
I believe