- 1

please can someone help identify whats wrong withthis code

players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190] group =[] ae=[] mean=sum(players )/len(players ) for player in players : a = (player-mean)**2 ae.append(a) sd = (sum(ae)/len(ae))**0.5 upp = mean - sd down = mean +sd for bb in players: if bb in range(upp, down): group.append(bb) print(len(group ))

21st Oct 2021, 7:27 PM
David Daniel
3 Answers
+ 1
1. Tag the right language in your post. It's Python not #. 2. Read the error message output after running your code. 3. Then make your range variables Integer, not Float: if bb in range(int(upp), int(down)):
21st Oct 2021, 9:46 PM
Coding Cat
Coding Cat - avatar
+ 1
If you do type(upp) and type (down) you will see that they are float and the function range() doesn't work with float. First you will need to convert the variable upp and down to integers. Also an advice would be to have more related with the meaning of the variables you call or if not, at least try to comment in order to understand the code if you want to used after a while or share with someone else. Good luck!
21st Oct 2021, 10:22 PM
Robert Marian Dragan
Robert Marian Dragan - avatar