Skip to content

Instantly share code, notes, and snippets.

@mayankdawar
Created February 22, 2020 20:23
Show Gist options
  • Select an option

  • Save mayankdawar/aa3048f70fbb0bbd577fbc639472f4a9 to your computer and use it in GitHub Desktop.

Select an option

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…
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()
@FarzadFahimifar
Copy link

#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