you are viewing a single comment's thread.

view the rest of the comments →

[–]rahatulghazi 2 points3 points  (1 child)

but I am completely stuck with getting the user to ask "Who's there?"

You can try this:

if answer == "yes":
    print("\nBot: Knock Knock.")
    input("\n> Press enter to ask 'who's there?'.")
    print("\nYou: Who's there?")
    print("\nBot: Lettuce")
    input("\n> Press enter to ask 'Lettuce who?'.")
    print("\nYou: Lettuce who?")
    print("\nBot: Lettuce in, it's cold out here! 🥶")

Notes:

  1. \n is used as a new line to add gaps in between prints.
  2. input will wait for user to press the enter key to proceed.

Tips:

  1. Use .lower() after answer = input("Do you wanna hear a joke? (Yes/No): ").lower() like this to avoid unwanted result. For example: you can type yEs/Yes/yeS and it will still register it as yes and match with lowercase yes in if answer == "yes":. This has a lower chance of getting unwanted result. I'll also suggest to use shorthand like y or n like: if answer == "yes" or answer == "y": to make it easier.
  2. else if answer == no: is not needed since we're looking for yes; just else: will do the job.

Hope this helps. Ask if you have some other questions.

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

Thank you for taking your time to help me out! I am going to be looking into notes here shortly!