fork download
  1. #!/usr/bin/env python3
  2.  
  3. def correct_sentence(text: str) -> str:
  4. text_list = [x for x in text]
  5. text_list[0] = text_list[0].upper()
  6.  
  7. if text_list[-1:] != '.':
  8. text_list.append('.')
  9.  
  10. return ''.join(text_list)
  11.  
  12. print(correct_sentence('greetings, friends'))
  13. print(correct_sentence('greetings, friends.'))
  14.  
Success #stdin #stdout 0.01s 27704KB
stdin
Standard input is empty
stdout
Greetings, friends.
Greetings, friends..