def revSentence(sentence):
    """
    A function which reverses the words in a sentence.
    
    Parameters:
        sentence(string); the sentence which is to be reversed.

    Returns:
        reversedSentence(string); the reversed version of 'sentence'.

    Raises:
        Exception; If an unexpected error occurs. Eg; if user enters an invalid input(int,float,list etc).   
    """

    try:
        
        reversedSentence = ""
    
        words = sentence.split(" ") # Getting a list of words in the sentence

        if len(words) == 1:
            return sentence
    
        for i in range(len(words)-1,-1,-1): # For loop which counts backwards from number of words - 1 till 0.
            
            reversedSentence = reversedSentence + words[i]     
        
            if i != 0: # Adding spaces between words while it is not the last word
                
                reversedSentence += " "
			
        return reversedSentence                                

    except:
        print("Error in reversing sentence : Please try again with a sentence of type 'string' in which the words are seperated with spaces.")