I noticed that in the following snippet both approaches give the same result:
>>> a = [1,2,3]
>>> print(a[0])
1
>>> print(a)[0]
1
>>>
I was a bit surprised, as I would have expected print(a) to return a string, so then subscript 0 to just return the first character (Ie: [). However, it seems Python interprets it as a list?
Anybody able to clarify please?
print(a)[0]givingTypeError: NoneType is not subscriptable.printis a statement, not a function) - it's alwaysprint a[0].(a[0]) is (a)[0] is a[0].