``````

In [48]:

import time
t1 = time.time()

``````
``````

In [49]:

t2 = time.time()
print(t2-t1)

``````
``````

3.779008626937866

``````
``````

In [10]:

str1 = ' a b c '
str1.replace(' ','')

``````
``````

Out[10]:

'abc'

``````
``````

In [7]:

import numpy as np
a = np.array([1, 2, 3, 4])
b = np.array([2, 4, 6, 8])
c=set(a).intersection(b)
c

``````
``````

Out[7]:

{2, 4}

``````
``````

In [28]:

for i in enumerate(b):
print(i)

``````
``````

(0, 2)
(1, 4)
(2, 6)
(3, 8)

``````
``````

In [26]:

a = [1, 2, 3, 4]
b = [2, 4, 6, 8]
[i for i, value in enumerate(b) if value in a]

``````
``````

Out[26]:

[0, 1]

``````
``````

In [8]:

[np.where(a == e) for e in c if np.where(a ==e)]

``````
``````

Out[8]:

[(array([1]),), (array([3]),)]

``````
``````

In [9]:

[np.where(b == e) for e in c if np.where(b ==e)]

``````
``````

Out[9]:

[(array([0]),), (array([1]),)]

``````
``````

In [10]:

x=[1,2,3,4,5]
y=[1,1,2,3,4]
set(x)

``````
``````

Out[10]:

{1, 2, 3, 4, 5}

``````
``````

In [11]:

set(y)

``````
``````

Out[11]:

{1, 2, 3, 4}

``````
``````

In [18]:

c=np.intersect1d(x,y)

``````
``````

In [19]:

[np.where(x == e) for e in c if np.where(x ==e)]

``````
``````

Out[19]:

[(array([0]),), (array([1]),), (array([2]),), (array([3]),)]

``````
``````

In [21]:

a_list = []

for e in c:
if np.where(x==e):
a_list.append(np.where(x==e))

``````
``````

In [22]:

a_list

``````
``````

Out[22]:

[(array([0]),), (array([1]),), (array([2]),), (array([3]),)]

``````