Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove space from print output - Python 3

I have this..

the_tuple = (1,2,3,4,5)
print ('\"',the_tuple[1],'\"')

showing

" 2 "

How can I get the output to show "2"?

like image 237
Steven Jones Avatar asked Dec 27 '22 03:12

Steven Jones


1 Answers

Use:

print ('\"',the_tuple[1],'\"', sep='')
                               ^^^^^^

Note that those escapes are completely unnecessary:

print ('"', the_tuple[1], '"', sep='')

Or even better, use string formatting:

print ('"{}"'.format(the_tuple[1]))
like image 89
Jon Clements Avatar answered Dec 28 '22 18:12

Jon Clements