I am try to check if a number "n" is in list1 or list2. First, I use for loop and append it to list1 (90...110) then, I repeat it for list2 (190...210) as well. Finally, I check if a number "n" is on list1 or list2.
Disclaimer?? I just figured out you can't get lists out of for loops(can you?) so, I built the for loop and stuff it inside a pre-determined list.
Full code;
n =[89]
lst1 = []
for i in range(90,111):
lst1.append(i)
print(lst1)
lst2 = []
for y in range(190, 211):
lst2.append(y)
print(lst2)
if n in lst1 or lst2:
print(f"{n} is in list1 or list 2")
else:
print(f"{n} is NOT in list1 or list 2")
I started Python just few days ago, so don't shit on me so much pls, thx.
EDIT: juanpa.arrivillaga's comment helped me to get it working. thanks man
I changed this
if n in lst1 or lst2:
print(f"{n} is in list1 or list 2")
to this
if (n in lst1) or (n in lst2):
print(f"{n} is in list1 or list 2")
but it doesn't for for some reason and I can't wrap my head around it.