Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a210807

Browse files
Added prog2 day 5
1 parent 7bac056 commit a210807

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

‎Day 5/common-elements-in-lists.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
l1 = list(map(int, input('enter the elements of the first list: ').split()))
2+
l2 = list(map(int, input('enter the elements of the second list: ').split()))
3+
l3 = list(map(int, input('enter the elements of the third list: ').split()))
4+
5+
i1, i2, i3 = 0, 0, 0
6+
7+
while i1 < len(l1) and i2 < len(l2) and i3 < len(l3):
8+
if l1[i1] == l2[i2] == l3[i3]:
9+
print(l1[i1])
10+
i1 += 1
11+
i2 += 1
12+
i3 += 1
13+
elif l1[i1] <= l2[i2] and l1[i1] <= l3[i3]:
14+
i1 += 1
15+
elif l2[i2] <= l1[i1] and l2[i2] <= l3[i3]:
16+
i2 += 1
17+
elif l3[i3] <= l2[i2] and l3[i3] <= l1[i1]:
18+
i3 += 1

‎Day 5/commonElements.o

-1.05 KB
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /