Q:

Find biggest element in a list in python?

I am new to python.I don't know much about it but when I did the program it says list index out of range or it doesn't even come.
a=[3,7,8,2,4,90,1]
f=0
for i in range(0,7,1):
  for j in range(1,7,1):
      if a[j]>a[i]:
        f=a[j]
print (f)

Could you help me with this? Can you tell me the mistakes or any other method(except the one using max() )? Thank you

A:

Indexes in Python are 0-based. So for a list with 7 elements, the valid indexes are [0] to [6]
So this line 
for j in range(i+1,7,1)

Should be
for j in range(7)

Or better, you could replace this whole code snippet with one line
print(max(ls))

If you'd like to manually do it using a loop
ls=[6,8,3,0,2,4,7]
largest = ls[0]
for num in ls:
    if num > largest:
        largest = num

>>> print(largest)
8

