separate output with comma in python 3 -


i need separate out comma print 1,2,fizz ect

for x in range (1, 21):     if x%15==0:         print("fizzbuzz",end=" ")     elif x%5==0:         print (("buzz"),end=" ")      elif x%3==0:         print (("fizz"),end=" ")     else:         print (x,end=" ") 

i can add comma " " list print comma @ end 1,2,fizz,4,buzz,fizz,7,8,fizz,buzz,11,fizz,13,14,fizzbuzz,16,17,fizz,19,buzz,

i've gone on notes , went on python tutorials not sure how rid of last comma or use more effective method rather add comma in instead of space.

i asked before confused wording question came out real confusing. understand may simple first time programming noob. lecturer hasn't explained me how can this. use help/ pointers. thanks.

instead of printing them immediately, put list of strings. join list commas , print resulting string.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -