message = "Hello World!"
vs
message = ("Hello World!")
As far as I have tested, both get interpreted with the same output. I’ve just started to learn python and wondering if those parentheses have any impact.
Advertisement
Answer
Both the implementations are same.
message= "Hello World!" print(type(message))
Output: <class ‘str’>
message = ("Hello World!") print(type(message))
Output: <class ‘str’>
Adding parenthesis to a string don’t automatically make them tuples. You need to add a comma after the string to indicate to python that it should be a tuple.
message = ("Hello World!",) print(type(message))
Output:<class ‘tuple’>