fork download
  1. # your code goes here
  2. def convert(s):
  3.  
  4. if(len(s) == 0):
  5.  
  6. return
  7.  
  8. s1 = ''
  9.  
  10. s1 += s[0].upper()
  11.  
  12. for i in range(1, len(s)):
  13.  
  14. if (s[i] == ' '):
  15.  
  16. s1 += s[i + 1].upper()
  17.  
  18. i += 1
  19.  
  20. elif(s[i - 1] != ' '):
  21.  
  22. s1 += s[i]
  23.  
  24. print(s1)
  25.  
  26.  
  27.  
  28. # Driver Code
  29.  
  30. def main():
  31.  
  32. s = "example-string-with-hyphens"
  33. convert(s)
  34.  
  35.  
  36.  
  37. if __name__=="__main__":
  38. main()
Success #stdin #stdout 0.05s 9688KB
stdin
example-string-with-hyphens
stdout
Example-string-with-hyphens