Code

Ask a Question

So far our programs say the same thing every time. Let's make them listen! input() pauses the program, waits for the user to type something, and gives you back what they typed:

name = input("What is your name? ")
print("Nice to meet you, " + name + "!")

If the user types Ada, the screen shows:

What is your name? Ada
Nice to meet you, Ada!

The text inside input(...) is the prompt, the question shown to the user. End it with a space so the answer doesn't stick to the question mark.

In PyQuest, what the "user" types comes from the Input box under the editor. Each line is one answer. For this lesson it already contains Lumen.

Assignment

  1. Ask What is your name? (with a space at the end) and store the answer in a variable called name.
  2. Print Welcome to the Lantern Guild, + the name + !

With the input Lumen, the output should be:

What is your name? Lumen
Welcome to the Lantern Guild, Lumen!