Skip to content

Instantly share code, notes, and snippets.

@z-------------
Last active September 18, 2015 12:30
Show Gist options
  • Select an option

  • Save z-------------/e241d8d3fa14a1540262 to your computer and use it in GitHub Desktop.

Select an option

Save z-------------/e241d8d3fa14a1540262 to your computer and use it in GitHub Desktop.
def gourdify(text): # start defining a function
words = text.split(" ") # split the text at each space
for i in range(0, len(words)): # for each i between 0 and the number of words
if words[i][0] is "G": # if the first letter of current word is "G"
words[i] = "Gourd" # set the whole word to "Gourd"
elif words[i][0] is "g": # if the first letter of current word is "g"
words[i] = "gourd" # set the whole word to "gourd"
return " ".join(words) # join the list of words with a space between each word
print(gourdify("Hello! I am feeling good"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment