Write a function that returns the largest element in a list
def return_largest_element(array):
largest = 0
for x in range(0, len(array)):
if(array[x] > largest):
largest = array[x]
return largest
Write a function that returns the largest element in a list
def return_largest_element(array):
largest = 0
for x in range(0, len(array)):
if(array[x] > largest):
largest = array[x]
return largest
how to find highest number in list without using max function python
Numbers = [90,78,34,50,100,99]
higest_number = 0
for number in Numbers:
if number > higest_number:
higest_number = number
find max value in list python
mylist = [1, 7, 3, 12, 5]
min_value = min(mylist)
max_value = max(mylist)
how to find largest number in list python without max
l=[]
n=int(input("enter the upper limit"))
for i in range(0,n):
a=int(input("enter the numbers"))
l.append(a)
maxno=l[0]
i=0
while i<n:
if l[i]>maxno:
a=l[i]
i=i+1
elif l[i]>maxno:
b=l[i]
i=i+1
print("max no is :",b)
break
else:
print("max no is",a)
break
#without using function i am just a beginner
#need improvement to shorten the code but plz without any function
how to find largest number in list python without max
n = int(input("Enter number of elements : "))
l = []
new=[]
dope = 0
for i in range(n):
l.append(int(input("Enter a number: ")))
print(l)
for i in l :
first = i
count=0
for x in l:
if x == first:
count+=1
new.append(count)
k=new[0]
print(new)
for i in new:
if i >=k:
dope = l[i]
print(dope)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us