Names and nicknames:
There are N persons in a society .You know the names and nicknames of all of the N people in society. Your task is to determine if there any two persons who have the same name and nickname
input:
The first line of input contains integer N
Each of next N lines contains two space separated strings denoting the name and nickname of person
output:
print YES if there is a pair of people with the same name and nickname otherwise print NO
i/p:
2
3
stephen steve
sato hanako
stephen steve
2
conan kun
subaro kun
o/p:
yes
no
i/P:
2
3
thomas cat
jerry mouse
johny bravo
3
nicolas tesla
saito san
nicolas tesla
o/p:
no
yes
number_society = int(input('Enter the number of societies:'))
ans = []
for _ in range(number_society):
num_people = int(input('Keep the number of people in societies:'))
people_lst = [input() for _ in range(num_people)]
# for _ in range(num_people):
# people_lst.append(input())
ans.append('no' if len(set(people_lst)) == len(people_lst) else 'yes')
print(*ans, sep='\n')
INPUT/OUTPUT:
Enter the number of societies:2
Keep the number of people in societies:3
stephen steve
sato hanako
stephen steve
Keep the number of people in societies:2
conan kun
subaro kun
yes
no
Enter the number of societies:2
Keep the number of people in societies:3
thomas cat
jerry mouse
johny bravo
Keep the number of people in societies:3
nicolas tesla
saito san
nicolas tesla
no
yes
Comments
Leave a comment