fork download
  1. class Solution(object):
  2.  
  3. def lengthOfLastWord(self, s):
  4. #without built in fns
  5. c= 0
  6. s= s.strip()
  7. for i in range(len(s)-1, -1, -1):
  8. if s[i]!= " ":
  9. c += 1
  10. else:
  11. return c
  12. return c
  13.  
Success #stdin #stdout 0.02s 7216KB
stdin
Standard input is empty
stdout
Standard output is empty