Answer the question
In order to leave comments, you need to log in
Can you explain how it works?
Code:
value = list(map(int, input().split())) (I understand this)
value_mid = sum(value:=value[:[i for i in range(len(value)) if value[i ] < 0][0]]) /len(value)
I understand everything, except for the line [:[i for i in range(len(value)) if value[i] < 0[0]]). Explain, please, very clearly what and how it does. And, preferably, write an equivalent. I'm more tormented by this [0] after the condition. Thanks to everyone who helped!
Answer the question
In order to leave comments, you need to log in
Tin. Let's expand it from outside to inside:
value_mid = sum(
value:=value[
:[
i for i in range(len(value)) if value[i] < 0
][0]
]
) /len(value)
Actually, you have written two different things:
first:
value[:[i for i in range(len(value)) if value[i] < 0][0]])
[:[i for i in range(len(value)) if value[i] < 0[0]])
[i for i in range(len(value)) if value[i] < 0]
value[:[i for i in range(len(value)) if value[i] < 0][0]]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question