 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Acronym in Python
Suppose we have a string s that is representing a phrase, we have to find its acronym. The acronyms should be capitalized and should not include the word "and".
So, if the input is like "Indian Space Research Organisation", then the output will be ISRO
To solve this, we will follow these steps −
- tokens:= each word of s as an array 
- string:= blank string 
- 
for each word in tokens, do - 
if word is not "and", then - string := string concatenate first letter of word 
 
 
- 
- return convert string into uppercase string 
Let us see the following implementation to get better understanding −
Example
class Solution:
   def solve(self, s):
      tokens=s.split()
      string=""
      for word in tokens:
         if word != "and":
            string += str(word[0])
      return string.upper()
ob = Solution()
print(ob.solve("Indian Space Research Organisation"))
Input
"Indian Space Research Organisation"
Output
ISRO
Advertisements
                    