Jul-10-2019, 03:42 PM
Hi,
I'm trying to sort a list of floats by descending order, and I am not sure why I'm getting a syntax error. I am using exactly what I found online.
I'm trying to sort a list of floats by descending order, and I am not sure why I'm getting a syntax error. I am using exactly what I found online.
probs = [] n = int(input()) for i in range(n): probs.append(float(input().split()[1]) probs.sort(reverse = True) #also tried newprobs = sorted(probs, reverse=True) tot = 0 for k in range(n): tot += probs[k] * (k + 1) print(tot)What am I missing? Isn't that the right syntax?