How I can find array in array

0 votes

Hi all, 

How I can find an array in an array, for example

Arr_all = [hi, hello, hi,hi]

Search_arr = [hi,hi]

Return start index 2
Nov 3, 2020 in Python by anonymous
• 8,880 points
51 views

1 answer to this question.

0 votes

I guess the given below will b easy to understand:

>>> a, b = ["hi", "hello", "hi", "hi"], ["hi", "hi"]
>>> [i for i in range(len(a)) if a[i: i+len(b)] == b]
[2]
answered Nov 3, 2020 by Gitika
• 65,930 points

Related Questions In Python

+2 votes
2 answers

In a list of dictionaries, how can I find the minimum calue in a common dictionary field.

There are several options. Here is a ...READ MORE

answered Apr 10, 2018 in Python by charlie_brown
• 7,780 points
479 views
0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,780 points
706 views
0 votes
1 answer

How can I define a multidimensional array in python using ctype?

Here's one quick-and-dirty method: >>> A = ((ctypes.c_float ...READ MORE

answered Oct 9, 2018 in Python by aryya
• 7,440 points
1,965 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,259 views
0 votes
0 answers
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,691 views
+2 votes
4 answers

How can I replace values with 'none' in a dataframe using pandas

Actually in later versions of pandas this ...READ MORE

answered Aug 13, 2018 in Python by bug_seeker
• 15,550 points
46,228 views
0 votes
5 answers

How can I use grep in Python?

The first part starts with grep , followed by ...READ MORE

answered Dec 13, 2020 in Python by Gitika
• 65,930 points
46,070 views