Ramcharan Yaragani
last year
Ramcharancountry asked

Can I use quotation marks for numbers in the print() function?

Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Ramcharan,

Yes, you can use quotes around numbers in print(), but it changes what you're printing.

For example:

print(65.6)      # prints a number  
print("65.6")    # prints a string that looks like a number

Both will display 65.6, but the first one is a number, and the second is a string. Python treats them differently.

If you're just printing a value, both work. But if you want to use that value later for math, keep it as a number — don’t put it in quotes.

If you have more questions, I am here to help.

Python
This question was asked as part of the Getting started with Python course.