February 2024
Beginner
352 pages
8h 16m
English
When you typed input(), you were typing the ( and ) characters, which are parenthesis characters. For input you can also put in a prompt to show to a person so they know what to type. Put a string that you want for the prompt inside the () so that it looks like this:
1 y = input("Name? ")
This prompts the user with “Name?” and puts the result into the variable y. This is how you ask someone a question and get the answer.
This means we can completely rewrite our previous exercise using just input to do all the prompting.
Listing 12.1: ex12.py
1 age = input("How old are you? ")
2 height = input("How tall are you? ")
3 weight = input("How much do you weigh? ")
4
5 print(f"So, you're ...Read now
Unlock full access