Reputation: 99
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"
?
Upvotes: 5
Views: 4964
Reputation: 411
Another f-string example,
the_tuple = (1,2,3,4,5)
print(f'"{the_tuple[1]}"')
gives
"2"
Upvotes: 0
Reputation: 142126
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]))
Upvotes: 11