How would one do this?
tried slipping in a cheeky
With these amendments i get the error "int expected str received" in turn it kills itself. Also declaring the "l = input()" to be int it also kills itself with "ValueError: invalid literal for int() with base 10: ''"
furthermore, with the script it its original state and changing the -1 to +1 were told too the input is 8 8 8 8 by the user my median is apparently 44?
Actually.
Applying the suggested math changes and by simplying changing the append to lst.append(int(l))
it bloody worked, so cheers
tried slipping in a cheeky
l = [int(lst) for lst in l]directly above the lst.append but that seemed to cause more issues
(Nov-05-2019, 02:56 PM)buran Wrote: With even number of elements median should be the mean of the middle two numbers (i.e. the true division of the middle 2 elements)-mid
andmid+1
, notmid-1
med = (srt[mid] + srt[mid+1]) / 2
Also because of using floor division you don't need to explicitly convert to int on line 8 (but this is just a note)
that said, you better add argument to median function, instead of using global variablelst
With these amendments i get the error "int expected str received" in turn it kills itself. Also declaring the "l = input()" to be int it also kills itself with "ValueError: invalid literal for int() with base 10: ''"
furthermore, with the script it its original state and changing the -1 to +1 were told too the input is 8 8 8 8 by the user my median is apparently 44?
Actually.
Applying the suggested math changes and by simplying changing the append to lst.append(int(l))
it bloody worked, so cheers