Here's my code:
import random
import keyboard
print("First, press enter to randomize your first mastery:")
while True:
if keyboard.is_pressed("enter"):
with open("masteries.txt", "r") as f:
masteries = f.read().splitlines()
random_mastery1 = random.choice(masteries)
break
file_name = random_mastery1.lower() + "_skills.txt"
print(f"Next, press enter to randomize your primary active skill for your first randomized mastery:")
while True:
if keyboard.is_pressed("enter"):
with open(file_name, "r") as skill_file:
skills = skill_file.read().splitlines()
random_skill = random.choice(skills)
break
print(f"Finally, press enter to randomize your second mastery:")
while True:
if keyboard.is_pressed("enter"):
with open("masteries.txt", "r") as f:
masteries = f.read().splitlines()
random_mastery2 = random.choice(masteries)
break
print(f"You'll be starting as {random_mastery1} with a primary active skill of {random_skill}." +
f" Your second mastery will be {random_mastery2}. Have fun!")
The program does exactly what I want it to core-functionality wise, but after pressing enter the first time to randomize the first mastery, it doesn't break and wait for the next two enter inputs, it just runs and completes after pressing enter once. Example:
First, press enter to randomize your first mastery:
**I press enter here**
Next, press enter to randomize your primary active skill for your first randomized mastery:
Finally, press enter to randomize your second mastery:
You'll be starting as Shaman with a primary active skill of Grasping Vines. Your second mastery will be Nightblade. Have fun!
Any idea on how to fix this or better implement what I am trying to accomplish?