Replit - Signal: Killed

Problem: Whenever I run my code it always says “repl process died unexpectedly: signal: killed”

Function of Program: A Work-In-Progress Random Quote Generator

How do I fix this? Is it due to my computer or Repl itself?

LINK: https://replit.com/@Wenhan-Benjamin/Draft-Quote-Generator#main.py

Here is my code:

image

Hi @Wenhan-Benjamin , welcome to the forums! When I run your program, I put in some names, but when I put ‘done’ in, the code still does not continue.

Can you also format your code using ```

1 Like

By the way, your CPU and RAM usage is very high because you have a while loop which is checking that condition hundreds and thousands of times without stopping.

Thank you, I will try and use your suggestions.

To lower the RAM and CPU, import time at the start of your code, and in the while loop, put in time.sleep(1)

Can you put the name=input( ) in the while loop, and put name=None above the while loop?

Certainly. Give me one second

print("Welcome to the Quote Generator!")
print("Enter a name (or 'done' to finish): ")

names = []
name = None

while name != "done":
  name=input()
  names.append(name)
  time.sleep(1)
1 Like

I think it works now.

It works now, thanks. Adding to this, I want to create a library to randomly generate a quote with the inputted names, is this possible?

Use the random library. Store the quotes in a list, and use random.choice(listOfQuotes) to generate a random quote from the list.

To remove the chosen quote from the list, do this:

import random
chosenQuote=random.choice(listOfQuotes)
listOfQuotes.remove(chosenQuote)

Understood, I’ll try that. If we wanted to change the quote amount (num of people needed for quote), could we do that? Maybe using random.choice(listOfQuotes(appendNum)) ?

You have to set the number of quotes to generate (use a for loop).

1 Like

I see, any examples, I’ll like to try them

I will message you privately.

I have messaged you.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.