-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathstory_generator.py
28 lines (20 loc) · 884 Bytes
/
story_generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import random
# Lists of story elements
characters = ['Alice', 'Bob', 'Charlie', 'Eve']
settings = ['a small town', 'a mysterious castle',
'a futuristic city', 'an enchanted forest']
actions = ['discovered a hidden treasure', 'solved a puzzling mystery',
'overcame their fears', 'saved the world']
conclusions = ['and they lived happily ever after.',
'and they vowed to continue their adventures.', 'and they returned home, forever changed.']
# Generate a random story
def generate_story():
character = random.choice(characters)
setting = random.choice(settings)
action = random.choice(actions)
conclusion = random.choice(conclusions)
story = f"Once upon a time, {character} found themselves in {setting}. They {action} {conclusion}"
return story
# Generate and print a story
story = generate_story()
print(story)