How can I print string without end of line character?

I'm trying to write a script that print first 50 numbers separated by , without any spaces, end of line characters between number. How can I do that?
I tried to use:
print ",",
however it generates extra space between words
#!/usr/bin/python
 
for i in range(1,51):
	if i > 1:
		print ","
	print "%d" % i

Open in new window

pmnoxAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
clockwatcherConnect With a Mentor Commented:
Try:
#!/usr/bin/python
 
import sys
for i in range(1,51):
     if i>1:
             sys.stdout.write(',')
     print i,

Open in new window

0
 
ramromconsultant Commented:

#!/usr/bin/python
 
print ",".join(str(i) for i in range(50))

Open in new window

0
 
pmnoxAuthor Commented:
thx. I didn't know that I can use sys.stdout.write function instread of print
0
All Courses

From novice to tech pro — start learning today.