import random
import timenum = 3
safenum = 1def storyBegin():print("Now you are in a island full of dragons.")print("In front of you,there are ", num, " caves.")print("In ", safenum, " cave, the dragon is friendly and will share his treasure with you.")print("The others dragon is greedy and hungry,and will eat you on sight.")print()def chooseCave():print("Which one do you choose?(1 to ", num,")")cave = int(input())if cave > 0 and cave <= num:return caveelse:print("You can only choose in 1 to ", num)chooseCave()def checkCave(chooseC):print("You approach the cave...")time.sleep(2)print("It is dark and spooky...")time.sleep(2)print("A large dragon jumps out in front of you!He opens his jaws and ...")time.sleep(2)print()friendCave = random.sample(range(1, num), safenum)if chooseC in friendCave:print("Gives you his treasure!")else:print("Gobbles you down in one bite!")if __name__ == "__main__":while True:storyBegin()chooseC = chooseCave()checkCave(chooseC)print("Do you want to play again?(yes or no)")againP = input()if againP not in ["y", "yes"]:break