Python | Print similar element in two sets.

In this program, we will take two input set from the user and print a similar element in the sets.


s = set(input("enter set elements"))
s1 = set(input("enter set elements"))
h = set()
for i in s:
    for e in s1:
        if i==e:
print("same elements are",h)
enter set elements1254789
enter set elements1459874
same elements are {'8', '7', '1', '4', '5', '9'}

Happy Coding!

Follow us on Instagram @programmersdoor

Join us on Telegram @programmersdoor

Please write comments if you find any bug in the above code/algorithm, or find other ways to solve the same problem.

Follow Programmers Door for more.

#blog #interview #placement #learn #computer #science

12 views0 comments

Recent Posts

See All

        Contact Us

  • LinkedIn
  • Facebook
  • Instagram

©2023 by Programmers Door