Home > Net >  How to remove the comma at the end of the sentence in Python
How to remove the comma at the end of the sentence in Python

Time:11-10

for i in range(5):
  print(i,end=',')

O/P : 0,1,2,3,4,

#I want to remove the comma after printing 4

CodePudding user response:

print(*range(5), sep=", ")

CodePudding user response:

It is not possible to remove the comma after it has been printed.

You could use ','.join([str(i) for i in range(5)])

  • Related