1
My code:
n = [int(input()) for c in range(0, 5)]
lista = list(range(0, 10))
if n not in lista:
print('1')
else:
print('2')
Digit 1, 2, 3, 4, 5 and the answer is "1", and the numbers from 1 to 5 are within the "list" that includes the numbers from 0 to 10, so I don’t think I’m correctly relating one list to the other. I would like to know how to check if the values of the first list are within the second, if the input is the example I used.
I don’t understand. You want to know if the variable is a list or if a certain value is inside the list?
– gato
I edited the question, now the doubt became clearer?
– Lucas Souza
Change your
if n not in lista:
forif set(n).intersection(lista):
, see if this helps you.– gato
It worked, you can explain to me how this structure works and give other examples of the type to use for if "n" is not in "list"?
– Lucas Souza
I already publish the answer and explain.
– gato