I recently started learning python.
So I wrote some small code, this code asks for 2 sizes of lists,
creates 2 lists with random integers from 09 and then spits out the
intersection between two lists.
The last "for" loop  I had trouble with it because at first my
"intersection" list had repetitions, then I looked up for an answer
and got what I have now, it works, however I don't know why. My
problem is grasping how "for i in l1 and in l2" works?
I know that "for i in range(k)" is going through the numbers 0k but
this strange for loop with the "and" operator just puzzles me.
l1 = []
l2 = []
C = []
s1 = int(input("Your 1st list size>"))
s2 = int(input("Your 2nd list size>"))
for i in range(s1):
from random import randint
k = (randint(0,9))
l1.append(k)
print("First List >" , l1)
for i in range(s2):
from random import randint
k = (randint(0,9))
l2.append(k)
print("Second List >" , l2)
for i in l1 and l2:
if i in l1 and l2:
C.append(i)
print("Intersection >" , C)
Please let me know if there is another place to submit such
questions(if here is not for suitable).
