Created
February 22, 2020 20:23
-
-
Save mayankdawar/aa3048f70fbb0bbd577fbc639472f4a9 to your computer and use it in GitHub Desktop.
Write code that uses the string stored in org and creates an acronym which is assigned to the variable acro. Only the first letter of each word should be used, each letter in the acronym should be a capital letter, and there should be nothing to separate the letters of the acronym. Words that should not be included in the acronym are stored in t…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 'so', 'it', 'and', "The"] | |
| org = "The organization for health, safety, and education" | |
| acro = "" | |
| lst = org.split() | |
| for i in lst: | |
| if i in stopwords: | |
| lst.remove(i) | |
| for j in lst: | |
| acro += j[0] | |
| acro = acro.upper() |
hadrocodium
commented
May 13, 2022
#why I got an error respond from below code
norg=org.split(" ")
acro=""
for i in norg:
if i is stopwords:
norg.remove(i)
else:
i=i[0]
i=i.upper()
acro=acro+i
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment