Skip to content

Instantly share code, notes, and snippets.

@roman-on
Created April 21, 2020 00:13
Show Gist options
  • Select an option

  • Save roman-on/9b4886f395aae089d8fe38459fda58ad to your computer and use it in GitHub Desktop.

Select an option

Save roman-on/9b4886f395aae089d8fe38459fda58ad to your computer and use it in GitHub Desktop.
"""
The function gets a list of strings of equal length. The function returns a string containing the list organs in paired positions,
violated in the Warford comma, as well as the last limb with the caption and before.
my_list = ["hydrogen", "helium", "lithium", "beryllium", "boron", "magnesium"]
format_list(my_list)
hydrogen, lithium, boron, and magnesium
"""
def format_list(my_list):
a = my_list[::2]
print (", ".join(a) + ", and", my_list[-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment