Skip to content

Commit dfb968a

Browse files
authored
Create Find Bigrams.py
1 parent e481847 commit dfb968a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

interview_query/Find Bigrams.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Write a function called find_bigrams that takes a sentence or paragraph of strings and returns a list of all its bigrams in order.
2+
3+
Note: A bigram is a pair of consecutive words.
4+
5+
6+
def find_bigrams(s):
7+
d = s.split()
8+
9+
d = [i.lower() for i in d]
10+
11+
res = []
12+
13+
for i in range(len(d) - 1):
14+
res.append((d[i], d[i + 1]))
15+
16+
print(res)
17+
return res

0 commit comments

Comments
 (0)