Created
December 26, 2019 06:39
-
-
Save aleybe/d691656ba9e5386d56f322622911f603 to your computer and use it in GitHub Desktop.
Example for blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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