Python ProgrammingPython Programming

Split string in Python to get first value?

s = 'canada-japan-australia'
l = s.split('-')[0]
print(l)

string = 'canada-japan-australia'
print(string[:string.index('-')])
Output
canada
canada