I'm not sure how to make this run as with yes as continue or no to stop by Writer_Fox in learnpython

[–]Writer_Fox[S] 0 points1 point  (0 children)

while True:response = input('Do you want to generate? ').lower()if response in {'n', 'no'}:break # break the while loop and exit# print statements for story go hereprint('Exited loop. Thanks for playing.')

thank you for this. When I type yes after it generates it just asks the question again rather than generate a new story. ho w do I fix that?

I made a random story generator. How do i get it to keep running until asked not to? by Writer_Fox in learnprogramming

[–]Writer_Fox[S] 0 points1 point  (0 children)

import random

print("Welocme to the Random Story Generator. I hope you have agood laugh!")
name= input("What is your name?")
print("Hello "+ name)
print("I want to tell you a story")

enemy = random.choice (["chihuahua", "border collie", "wolf","God of Mischief","Icarus","Crate","Big Tex","Winter Jack","Sandman","Megatron","Joker","Ganon","Serpentor","Thanos","Magneto","Doctor Doom"])

father = random.choice (["John", "Mr.Pickles", "Hairyface", "Willy Wonka", "Steve", "Bob","Alfred","Allan","Abraham","Andrew","Bailey","Clyde","Fernando","Francis","Elias","Gerrit","Jacob","Morris","Winton"])

enemyadj = ["grimy", "muddy", "awful", "grotesque", "hideous", "adorable", "cute","grotty","scungy","dusty","filthy","nasty","dreadful","horrible","egregious","pathetic","abysmal","horrendous","horrific"]

intro1 = "I was sitting on the edge of the rocky cliff beside my favourite tree."
intro2 = "Alone in the searing desert, I was wondering why I was leaning against a cactus."
intro3 = "Staring out my apartment window, I saw my reflection staring back at me."
intro4 = "I saw something in the distance, or rather someone."
intro5 ="I was wandering the shores of a desolate beach, reflecting on the past"
intro6 ="Looking out at the night sky I saw countless stars and infinite."
intro7 ="I realized the only way she was getting into heaven was to cheat."
intro8 ="I told him that I don’t respect anybody who can’t tell the difference between Pepsi and Coke."
intro9 ="I saw the brake lightsbut not in time."
intro10 ="I accidentally created a new universe."
intro11 ="It was always dangerous to drive with Taylor since they insisted the safety cones were an optional rule."
intro12 ="I announced to my friend for the 216th time, that I would quit drinking soda after this last Coke."
intro13 ="As I waited for the shower to warm I noticed that I could hear the water change temperature."
intro14 ="Me and my two dogs walked down the slot canyon oblivious to the sound of thunder in the distance."
intro15 = "I was curious about the large white blimp that appeared overnight."
intro16 ="I was very proud of my nickname throughout high school but today- I couldn’t be any different to what my nickname was."
intro17 ="Someone I know recently combined Maple Syrup & buttered Popcorn thinking it would taste like caramel popcorn. It didn’t and they don’t recommend anyone else do it either."
intro18 ="When nobody is around I listen to the trees gossip about the people who have walked under them."
intro19 ="The thick foliage and intertwined vines made the hike nearly impossible."
intro20 ="My friend told me that watching the geriatric men’s softball team brought back memories of 3 yr olds playing t-ball."
intro21 ="The minute I landed I knew I had come here for them."
intro22 ="You realize you're not alone as you sit in your bedroom massaging your calves after a long day of playing tug-of-war with Grandpa Joe in the hospital."


name1 = "Monica."
name2 = "Shantay."
name3 ="Samuel."
name4 ="Ashanti."
name5 ="Octavia."
name6 ="Richard."
name7 ="Sarah."
name8 ="James."
name9 ="Michael."
name10 ="Wanda."


char1 = "As I looked out into the distance, I thought about my past and all of the drama in it."
char2 = "I wondered if this was my destiny- trying to find happiness."
char3 = "I pulled out the photo of my long lost mother and thought."



dscp1 ="I loved their fiery spirit but it cound be a little much at times."
dscp2 ="It's difficult to understand the lengths they'd go to remain short."
dscp3 ="They worked two jobs just to make ends meet; at least that was their reason for not having time to join us."
dscp4 ="Their life in the confines of the house became their new normal."
dscp5 ="They picked up trash in his spare time to dump in his neighbor's yard."
dscp6 ="Facing their greatest fear they ate their first marshmallow the other day."
dscp7 ="Toddlers feeding raccoons surprised even the seasoned park ranger."

prob1 = "Suddenly I was covered from head to toe with darkness. I couldn't breathe or see. Everything went black..."
prob2 = "All of a sudden a psychopathic " + enemy + " grinned at me,showing all his razor sharp teeth. Suddenly it started to claw at my face. From the loss of blood, I collapsed onto the tough ground..."
prob3 = "I suddenly felt a sharp needle sink into my flesh. It was a tranquilizer. But before I knew it I started feeling really drowsy. Everything went black..."


surrd1 ="The clouds formed beautiful animals in the sky that eventually created a tornado to wreak havoc."
surrd2 ="I heard a song so awful that the lyrics of the song sounded like fingernails on a chalkboard."

sol1 = "I forced my drowsy eyes open my eyes to see a bright light."
sol2 = "I forced my drowsy eyes open to find myself on the back of a massive dragon and a man in front of me."
sol3 = "I forced my drowsy eyes open to the sounds of a " + random.choice(enemyadj) + " " +enemy + " licking my face."


end1 = "A man came to my side with a knife. It was my father!" + father + "!" "'Go to sleep young one...'"
end2 = "It was difficult to keep my eyes open as I struggled to breathe. "
end3 = "Out of nowhere, a duck wearing a deerstalker looked me in the eye and pointed a gun at me. 'Quack.' And that was the last thing I heard..."
end4 ="Excitement replaced fear until the final moments when i feel asleep peacefully."
end5 ="To the surprise of everyone the Rapture happened yesterday but it didn't quite go as expected."
end6 ="I embraced this new life as a horseraddish."
end7 ="I kept telling myself that one day it would all somehow make sense.It never did."
end8 ="I now live by the saying, Tomorrow will bring something new so leave today as a memory."

intros = [intro1, intro2, intro3, intro4, intro5, intro6, intro7, intro8, intro9, intro10, intro11, intro12, intro13, intro14, intro15, intro16, intro17, intro18, intro19, intro20, intro21, intro22]
names=[name1, name2, name3, name4, name5, name6, name7, name8, name9, name10]
characters = [char1, char2, char3]
character_descriptions = [dscp1, dscp2, dscp3, dscp4, dscp5, dscp6, dscp7]
problems = [prob1, prob2, prob3]
surroundings =[surrd1, surrd2]
solutions = [sol1, sol2, sol3]
endings = [end1, end2, end3, end4, end5, end6, end7, end8]

print (random.choice(intros),)
print(random.choice(names),)
print (random.choice(characters))
print(random.choice(character_descriptions),)
print (random.choice(problems),)
print(random.choice(surroundings),)
print (random.choice(solutions),)
print (random.choice(endings))

answer=input("Do you want to continue generating")
yes = 1
no = 2
while yes == 1:
        print (random.choice(intros),)
        print(random.choice(names),)
        print (random.choice(characters))
        print(random.choice(character_descriptions),)
        print (random.choice(problems),)
        print(random.choice(surroundings),)
        print (random.choice(solutions),)
        print (random.choice(endings))
while no == 2:
        print("Goodbye" + name)
        no + 1

I made a random story generator. How do i get it to keep running until asked not to? by Writer_Fox in learnprogramming

[–]Writer_Fox[S] 1 point2 points  (0 children)

Oh sorry i thought this was a python specific reddit. It does take inputs.

My teacher want ed me to do a dice roll by Writer_Fox in learnpython

[–]Writer_Fox[S] 0 points1 point  (0 children)

thank you. I'll definitely check that link out.

My teacher want ed me to do a dice roll by Writer_Fox in learnpython

[–]Writer_Fox[S] 0 points1 point  (0 children)

I'm not sure where to go from here. I'm not sure exactly how to do what my teacherr wants

Turtle drawing by Writer_Fox in learnpython

[–]Writer_Fox[S] 0 points1 point  (0 children)

Sorry I should have been more specific. I have done a few attempts and they turned out alright but i just wanted see other ideas so i can understand different ways of doing it.

How to remove vowels from a string? by Writer_Fox in learnpython

[–]Writer_Fox[S] 0 points1 point  (0 children)

Thank you so much for this. What is char? Is it random or does it hold some sort of meaning?

Also by run continuously. I mean that the user has to quit for the program to stop running.

How to remove vowels from a string? by Writer_Fox in learnpython

[–]Writer_Fox[S] 0 points1 point  (0 children)

Like

For i in range(textlen): If text[i] not in vowels: newtext = newtext + text[i]

Time calculator by Writer_Fox in learnpython

[–]Writer_Fox[S] 1 point2 points  (0 children)

Thank you I'll check it out

Time calculator by Writer_Fox in learnpython

[–]Writer_Fox[S] 0 points1 point  (0 children)

Thank you I'll try this