Created
July 18, 2018 02:50
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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