-2

I am writing a function which is supposed to get the user's response, yet when I run the file nothing happens, its just an empty screen, how do I fix that? I tried searching up in stackoverflow but I couldnt find what im looking for, thanks in advance :)

def get_user_response():
  while True:
    try:
      print ('Enter the number of clickbait headlines to generate: (0 to exit)')
      user = int(input('> '))
      print ('HEADLINES')
      if user == 0:
        for x in range (0,4):
          l = "Exiting Program" + "." * x
          print (l, end="\r")
          sleep(1)
        break
      else:
        print ('a')
    except:
      print ('Invalid - Enter an integer')
rnsleep
  • 3
  • 4

2 Answers2

1

You defined a function but never called it anywhere. That's why the program is not running in the first place. Just write

get_user_response()

anywhere outside of the function.

Also consider wrapping only the user input line into the try except statement, otherwise you will literally catch every possible error that might occur in your function without ever getting an error message.

Dominic K.
  • 19
  • 5
0
def get_user_response(trueorfalse):
     while trueorfalse:
           .....your codes
get_user_response(True)

your function should have arg like thaht

berk
  • 34
  • 3