Ask the user if they want to repeat the same task again

You can enclose your entire program in another while loop that asks the user if they want to try again.

while True:
  # your entire program goes here

  try_again = int(input("Press 1 to try again, 0 to exit. "))
  if try_again == 0:
      break # break out of the outer while loop

Leave a Comment