def firstLine(s):
 try:
  i = s.index('\n')
  return s[:i]
 except ValueError:
  return s

def firstLine ( s ) : try : i = s . index ( '\n' ) return s [ : i ] except ValueError : return s
return the first line of the given string .