0
This is the question [2,] how many no are there
I wrote it has two bcz lists have null spaces at the end .But the correct answer is one.
3 Answers
+ 7
You can end lists, tuples etc. with a comma, it doesn't make a difference. [1,] is the same as [1]. [1, 2,] is the same as [1, 2].
If a tuple has only one element you need to use a comma:
t = (1) # not a tuple but an integer
t = (1,) # tuple with one element
t = 1, # also a tuple with one element
These are all equal:
t = (1, 2,)
t = (1, 2)
t = 1, 2,
t = 1, 2
+ 3
What ?? please explain more understandable.
+ 2
The correct answer would be one. It is true that arrays have an implicit null character in memory, but the length of the array (in this case) is one because 2 is the only element it contains.
If you are programming in Python, try this:
my_list = [2]
print(len(my_list)) # output: 1
Edit: also, the null character is not a number, it is a special kind of character.