How to print a variable inside quotation marks in Python

4 Answers

0 votes
name = "R2D2"

print(f'"{name}"')


'''
run:

"R2D2"

'''

 



answered 4 days ago by avibootz
0 votes
name = "R2D2"

print('"' + name + '"')


'''
run:

"R2D2"

'''

 



answered 4 days ago by avibootz
0 votes
name = "R2D2"

print(repr(name))


'''
run:

'R2D2'

'''

 



answered 4 days ago by avibootz
0 votes
name = "R2D2"

print('"{}"'.format(name))


'''
run:

"R2D2"

'''

 



answered 4 days ago by avibootz
...