Help Needed : script weird result.
mohan4h at gmail.com
mohan4h at gmail.com
Sat Sep 1 21:12:35 EDT 2018
On Sunday, September 2, 2018 at 1:12:17 AM UTC+8, moh... at gmail.com wrote:
> All,
>
> I m trying to run this small script to find the lowest of the given array of numbers. The script works fine for various combination of inputs but fails in a weird way for a particular set of inputs, can anyone point the mistake in the script and the behavior.
>
> Script
>
> x = input ("Enter the numbers separated by space and press ENTER :")
> x = x.split(" ")
>
> def checkmin(arr):
> lowest = arr[0]
> for count in range(0,len(arr),1):
> if arr[count] < lowest :
> lowest = arr[count]
> else :
> pass
> print (lowest)
> return lowest
>
> minimum = checkmin(x)
> print ("Lowest : {0}".format (minimum))
>
>
> Weird output is as below.
>
> ================== RESTART: C:\Users\mohan\Desktop\temp.py ==================
> Enter the numbers separated by space and press ENTER :5 90 63 82 59 24
> 5
> 5
> 5
> 5
> 5
> 24
> Lowest : 24
>
> Regards
> Mohan C
Thanks to Duncan, Joel, Peter and Dan.
Now I understood what was wrong with the script and i fixed it,
Now my scripts executes as expected and also i understand a concept in type casting.
As always this group is awesome and responsive, Thanks again guys.
Regards
Mohan C
More information about the Python-list
mailing list