197k views
1 vote
g create your own min function that finds the minimum element in a list and use it in a separate function

1 Answer

7 votes

Answer:

Following are the code to this question:

def min_function(x):#defining a method min_function

mini= x[0]#defining a variable to hold list value

for i in x[1:]:#defining for loop to count values

if i < mini: #defining if block to check minimum value

mini = i #holding minimum value in mini variable

return (mini)#return value

print(min_function([9,8,7,6,5,4,3,2,1,11,19]))#use print method to call min_function

Output:

1

Step-by-step explanation:

In the above code, a method min_function is defined, that holds a list as the parameter and inside the method, a mini variable is defined, that holds a list value and use a for loop to define a condition to check the minimum value in the list and store its value in a mini variable and use a return keyword to return its value.

At the last print, the method is used to call the above method with accepting list values.

User BrandConstantin
by
5.4k points