Skip to content

Instantly share code, notes, and snippets.

@AnisahTiaraPratiwi
Created March 22, 2021 06:26
Show Gist options
  • Select an option

  • Save AnisahTiaraPratiwi/7fdc7e21de27a897a507dded5cb0a5ad to your computer and use it in GitHub Desktop.

Select an option

Save AnisahTiaraPratiwi/7fdc7e21de27a897a507dded5cb0a5ad to your computer and use it in GitHub Desktop.
Fill in the gaps in the initials function so that it returns the initials of the words contained in the phrase received, in upper case. For example: "Universal Serial Bus" should return "USB"; "local area network" should return "LAN”
def initials(phrase):
words = phrase.split()
result = ""
for word in words:
result += word[0].upper()
return result
print(initials("Universal Serial Bus")) # Should be: USB
print(initials("local area network")) # Should be: LAN
print(initials("Operating system")) # Should be: OS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment