This Python program is designed to standardize mobile numbers. It takes a list of mobile numbers as input, sorts them, and then formats them in a specific pattern. The pattern is '+91' followed by a space, then the first five digits of the number, another space, and finally the last five digits of the number.
CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷
The solution works by first reading the number of mobile numbers to be standardized. It then reads each mobile number, trims it to the last 10 digits, and stores it in a list. The list of mobile numbers is then sorted. Finally, each mobile number in the sorted list is printed in the desired format. The formatting is done using Python's f-string formatting feature, which allows for a concise and readable way to embed expressions inside string literals for formatting.
n = int(input())
ar = []
for _ in range(n):
tmp_str = input()
tmp_str = tmp_str[len(tmp_str) - 10 :]
ar.append(tmp_str)
ar.sort()
for item in ar:
print(f"+91 {item[:5]} {item[5:]}")
If you have a HackerRank coding test coming up, you can use CodeRankGPT to your advantage. It will assist you during your interview and help ensure you get the job.
AI is here now, and other candidates might be using it to get ahead and win the job. 🧐
The form has been successfully submitted.