MATLAB has a very convenient syntax for getting half of a list:
x(1:end/2)
The syntax I know for python to do this is
x[:len(x)/2]
This is fine in this case, because len(x) is easy to write. But this syntax becomes more than a pain when the name of the list is long (as they sometimes need to be), and even more so when there is a list of similar long names.
I know this is a real shot in the dark, but does python have any syntax option like MATLAB’s?
There is no specialized syntax. If you need to do it a lot, write a function: