Wednesday, August 5, 2020

Python Class 177 (Compare two lists) - Kapil

import random

I/P:
l1 = list(range(5))
random.shuffle(l1)


l2 = list(range(10))
random.shuffle(l2)

count = 0
for i in l1:
    for j in l2:
        if i == j:
           print(i)
           count +=1
print("Common numbers are as following: ", count)

-------------------------------------------------

O/P:
0 4 3 1 2 Common numbers are as following: 5

-------------------------------------------------


===============================================================
https://github.com/bornfreesoul/PythonLessons
https://www.youtube.com/channel/UCe0rLJmSQXNoK2Mo2eMVuvg

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Blockchain: 101 (By - Kapil Sharma)

 https://testing-mines.blogspot.com/2021/10/blockchain-101-by-kapil-sharma.html Blockchain through the following attributes: Distributed:  T...