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 4, 2020 in Python by anonymous
• 8,870 points
428 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 4, 2020 by Gitika
• 65,770 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,720 points
1,406 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,720 points
2,326 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,460 points
4,869 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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,422 views
0 votes
1 answer
+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,790 points
4,042 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,510 points
122,280 views
0 votes
5 answers

How can I use grep in Python?

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

answered Dec 14, 2020 in Python by Gitika
• 65,770 points
72,469 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP