s = (‘Coding Blocks’)
print(type(s))
This is one of the questions of the quiz on python data structures. The correct answer showing is string why is it not a tuple?
s = (‘Coding Blocks’)
print(type(s))
This is one of the questions of the quiz on python data structures. The correct answer showing is string why is it not a tuple?
Hello Aarushi, we consider tuple as a set of elements enclosed by a paranthesis separated by the comma
Like (1,2,3,4) this is a tuple
(“Abc”,“vbd”) this is a tuple
We can also put the comma at the end to ensure that it can also consist of more elements
Like if you have only single element and if you want to count it as a tuple then you need to put the comma after that.
Like
a = (5) this is an integer
but now a = (5,) this is a tuple
so same for your query
s = (‘Coding Blocks’)
print(type(s)) this is string
but if we use comma after the coding blocks string it will be counted as a tuple
s = (‘Coding Blocks’,)
print(type(s)) this is tuple
I hope it is clear to you. In case it is clear to you pls mark it as resolve and provide the rating as well as feedback so that we can improve ourselves.
In case there is still some confusion pls let me know, I will surely try to help you out.
Thanks
Happy Coding !!