• How does this work?

Question related to mission Correct Sentence

 

The code is (text[0].upper() + text[1:] + '.' * (not text.endswith('.'))), how does this code turn 'welcome to new york' to 'Welcome to New York'?