Skip to content

Instantly share code, notes, and snippets.

@aleybe
Created December 26, 2019 06:39
Show Gist options
  • Save aleybe/d691656ba9e5386d56f322622911f603 to your computer and use it in GitHub Desktop.
Save aleybe/d691656ba9e5386d56f322622911f603 to your computer and use it in GitHub Desktop.
Example for blog post
import random
def create_rick_and_morty_adventure(input_string: str):
""" This is a method that grabs random words from a string """
# First create a list from the input string
start_list = input_string.split()
if len(start_list) > 1:
# our list is more than one word. Which means we can randomise!
random_selection = []
for x in range(0, 3):
random_selection.append(random.choice(start_list))
return(random_selection)
else:
return ("Sorry you did not give enough words")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment