def isValidWord(word, hand, wordList):
    """
    Returns True if word is in the wordList and is entirely
    composed of letters in the hand. Otherwise, returns False.

    Does not mutate hand or wordList.
   
    word: string
    hand: dictionary (string -> int)
    wordList: list of lowercase strings
    """
    hand1=hand.copy()
    if word not in wordList:
        return False
    for i in word:
     if hand1.get(i,0)>0:
        if hand1[i]<=0:
            return False
        else:
            hand1[i]=hand1[i]-1
     else:
         return False
    return True