Step 5: Define get_random_word function

  1. This function takes a list words as an argument.
  2. The function picks a random position (index) in the list.
  3. Returns the word from the words list at that position.
๐Ÿ’ก Hint
  • Use randrange(...) or randint(...) from the random module to generate a random number that can be used as an index when accessing an item in a list. Store this number in a variable.
โ„น๏ธ More Information
  • .randrange(start, stop) or .randrange(stop) returns a random integer starting from start (or 0 by default) up to but not including stop.
  • .randint(a, b) returns a random integer between a and b, including both values.
  • Make sure the index is within the valid range of the words list. The valid index range is from 0 to len(words) - 1, where len(words) returns the number of items in the list words.
  • To call a function from a module: moduleName.functionName(...)
  • To return a word from the list of words, think about how to access an item from a list.
โญ Example
  • word_list[index] returns the item at the specified index in the list.
โœ… Code Runner

Define get_random_word function

Type or paste your code and run.