miércoles, 4 de septiembre de 2024

getting to value on a list and its position

 >>> scores =[103, 88, 67, 54, 23, 971, 34, 679]


>>> top=[a for a in scores if a==max(scores)]  ##top socres

[971]

>>> 


>>> pos=[scores.index(a) for a in scores if a==max(scores)]  ##position on the list

[5]


No hay comentarios:

Publicar un comentario