title: Upper case only on specific characters in python string/list
body: <p>I am learning python list and string functions. I need to write a specific function. My function returns correctly the Else task. However, I am not able to capitalize only the first and last letter of each word in the given sentence. Thank you for your help, I can only use basic functions as given in the hints.</p>
  <p>Here is the task:
  <strong>If</strong> the given sentence starts with *, capitalizes the first and last letters of each word in the sentence, and returns the sentence without *.
  <strong>Else</strong>, joins all the words in the given sentence, separating them with a comma, and returns the result.</p>
  <p>For example
  if we call capitalize_or_join_words(&quot;*i love python&quot;), we'll get &quot;<strong>I LovE PythoN</strong>&quot; in return.
  If we call capitalize_or_join_words(&quot;i love python&quot;), we'll get &quot;<strong>i,love,python</strong>&quot; in return.
  If we call capitalize_or_join_words(&quot;i love    python  &quot;), we'll get &quot;<strong>i,love,python</strong>&quot; in return.</p>
  <p>Hints:
  The <strong>startswith()</strong> function checks whether a string starts with a particular character. The <strong>capitalize()</strong> function capitalizes the first letter of a string.The <strong>upper()</strong> function converts all lowercase characters in a string to uppercase. The <strong>join()</strong> function creates a single string from a list of multiple strings</p>
  <pre><code>def capitalize_or_join_words(sentence):
  
  if sentence.startswith('*'):
      s = sentence.replace('*','')
      s2 = s.split()
      
      s3 = []
  
      for word in s2:
          s3 += word.capitalize()
      
      temp = &quot;,&quot;.join(s3)
      sentence_revised = temp
      
  else:
      
      s = sentence.split()
      sentence_revised = &quot;,&quot;.join(s)
  
  return sentence_revised
  </code></pre>