Created
February 21, 2024 17:35
-
-
Save walbon/3ece622862bec998fabf6a5814836f9f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
adjectives = [ | |
"blue", "red", "green", "yellow", "purple", "orange", | |
"happy", "sad", "angry", "calm", "sleepy", "hungry", | |
"big", "small", "tall", "short", "wide", "narrow", | |
"soft", "hard", "rough", "smooth", "hot", "cold", | |
] | |
nouns = [ | |
"bird", "cat", "dog", "fish", "mouse", "snake", | |
"tree", "flower", "grass", "mountain", "river", "ocean", | |
"house", "car", "boat", "plane", "train", "bus", | |
"computer", "phone", "book", "pencil", "paper", "chair", | |
] | |
def generate_name(): | |
"""Generates a random name using an adjective and a noun.""" | |
adjective = random.choice(adjectives) | |
noun = random.choice(nouns) | |
return f"{adjective}-{noun}" | |
def random_name_generator(): | |
"""Infinitely yields random names.""" | |
while True: | |
yield generate_name() | |
# Example usage | |
for name in random_name_generator(): | |
print(name) | |
# Example output: blue-bird, red-cat, green-dog, ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment