### Thread: Max value in for loop

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
2
Rep Power
0

#### Max value in for loop [SOLVED]

So i want to know the highest value in the 'for' loop listed below, but it doesnt work :s notes are added in code
Code:
```import math
def main():
global r,n
n = int(input('Name the amount of individuals: '))
r = int(input('Name the amount of recombinant children: '))
print('')
bereken()

def bereken():
global LOD
for x in range(1,51,1):
z = x/100
LOD = math.log10 (((1-z)**(n-r)*(z**r))/(0.5**n))
print('At a recombinant fraction of ',float(z))
print('The maximum LOD-value is: ',float(LOD))
print('')
MAX()

def MAX():
print('The highest LOD-value is: ',max(LOD))

main()

#the LOD is 0.0 becouse x=50 (the sum equals 0)
#and in the loop LOD is overwritten each time (50 times total)
2. You're using python version 3?
Code:
```def bereken():
LOD = list()
for x in range(1,51,1):
z = x/100.0
LOD.append(math.log10 (((1-z)**(n-r)*(z**r))/(0.5**n)))
print('At a recombinant fraction of ',z)
print('The maximum LOD-value is: ',LOD[-1])
print('')
MAX(LOD)```
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
2
Rep Power
0
thanks, worked out!