I want to extract the next part (from '-') of the file name which is 000.xyz.
N.B. [file name is Axx-000.xyz]
def get_rank(xyz):
pref = xyz.split('-')[1]
pref = pref.replace('.xyz', '')
return pref
If I try get_rank('Axx-000.xyz')
which will return 000
.
I just started python lang I just want to clarify whether what I think how it works is correct or not.
So the first line of the function will split the string to list of strings.
- if I do
get_rank('Axx-000.xyz')
'Axx-000.xyz'
will turn into
['Axx', '000.xyz']
then store 1st order element (000.xyz
) aspref
- the second line will replace/erase the string (.xyz) to nothing. so
pref = 000
Is this correct process of the function?