Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Created July 18, 2018 02:50
Show Gist options
  • Save BlogBlocks/12ceb07ea8760f72bf9a5bf9f7eb51f5 to your computer and use it in GitHub Desktop.
Save BlogBlocks/12ceb07ea8760f72bf9a5bf9f7eb51f5 to your computer and use it in GitHub Desktop.
printing or using a list without tailing comma / final comma / comma at end
#!/user/local/bin
# filename: nocomma.py
namesinalist = "jack,myra,Darwin,Daryl,Christine"
namesinalist = namesinalist.split(",")
print "----with final comma--------------------"
for name in namesinalist:
#with final comma
print name+',',
text = """
for name in namesinalist:
#with final comma
print name+',',
"""
print text
print "========================================"
print "----with no final comman----------------"
#for name in namesinalist:
print ', '.join(namesinalist)
print 'print \', \'.join(namesinalist)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment