Problem Statement:
It’s very simple, we need to find the number of strings equal to each other, and that’s it. This was the technical intro to the problem. Now, let’s see the actual problem. We are given some names and we need to find the number of pairs that exist. A pair means two names are equal to each other.
Code to find Names and Nicknames in Python:
t = int(input('Enter number of test cases: ')) for i in range(t): n = int(input('\nEnter number of people: ')) names = [] for j in range(n): names.append(input('Enter new name: ')) count_ = [] for i in names: count_.append(names.count(i)) if max(count_)>1: print('Yes, there is 1 or more pair(s) exist') else: print('No pair exist')
Output:
Also Read:
- Hyphenate Letters in Python
- Earthquake in Python | Easy Calculation
- Striped Rectangle in Python
- Perpendicular Words in Python
- Free shipping in Python
- Raj has ordered two electronic items Python | Assignment Expert
- Team Points in Python
- Ticket selling in Cricket Stadium using Python | Assignment Expert
- Split the sentence in Python
- String Slicing in JavaScript
- First and Last Digits in Python | Assignment Expert
- List Indexing in Python
- Date Format in Python | Assignment Expert
- New Year Countdown in Python
- Add Two Polynomials in Python
- Sum of even numbers in Python | Assignment Expert
- Evens and Odds in Python
- A Game of Letters in Python
- Sum of non-primes in Python
- Smallest Missing Number in Python
- String Rotation in Python
- Secret Message in Python
- Word Mix in Python
- Single Digit Number in Python
- Shift Numbers in Python | Assignment Expert
- Weekend in Python
- Shift Numbers in Python | Assignment Expert
- Temperature Conversion in Python
- Special Characters in Python
- Sum of Prime Numbers in the Input in Python