Can someone clarify please?


Sorry, but what is the point of converting pi into a string? Won't print(pi) give the exact same result as print(str(pi))


There is a difference.


x = "3" #x is a string here
y  = 3   # y is a number here

#when you do this..

print x # it will print 3
print y #it will print 3

so it means that both are Equal?
when print acts on string values ,It omits the quotes and just prints it.

when we do this..

x = 3
x = str(3)

then it means that we're making 3 a string.
Its no more a number but a string"3".
so str() converts a number 3 (int value) into a string value "3"


Hey there thank you for the quick reply. So basically, in your case, on paper, print will produce the same result for x and y. But in actual fact, they are of different variable types?


Yup! print is just for representation.
and both (x,y) are still different data types.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.