operation with vectors

0

I have two m1 and m2 variables that change each set of data I import and a vector (measures) with the values, I need to see if the vector values are greater than M1 or smaller than M2 and exclude them if they are. And list them to see which values were deleted. bold text

    
asked by anonymous 01.05.2018 / 00:35

1 answer

0

o .split () it "breaks" the string typed by space that is the default, so the user types 1 2 and m1 gets 1 and m2 gets 2, but they are strings, so use o. map () to do the conversion of these entries to int and .remove () takes a value and removes it from the list if the condition is met. If you still do not understand, check the Python Lists.

lista = [10,20,30]
excluidos = []
m1, m2 = map(int, input().split()) # convertendo os valores digitados para int
for n in lista:
    if n > m1 or n < m2:
            excluidos.append(n)
            lista.remove(n)
print(excluidos)
    
01.05.2018 / 01:26