- "Answer" redirects here. For the information that this block reports, see Answer (value).
The answer block is a sensing block and a reporter block. The block returns the most recent text inputted with the Ask () and Wait block. When nothing has been inputted yet, the value will hold nothing. It was introduced in Scratch 1.4.
This block can be displayed as a Stage monitor.
As this block stores inputted text, it is very useful where a script has to refer to what has been inputted. For example, there are chat bots that allow the user to input their name. If the script must access their name, the answer block can be used.
Some common uses for the answer block:
- Retrieving information inputted by the user
ask [What's your favorite color?] and wait say (join (answer) [ is my favorite color too!] )
- Storing user input from the ask () and wait block
when green flag clicked ask [Which level do you want to play?] and wait set [level v] to (answer) broadcast (join [start level ] (level))
- Checking if an answer is correct
when green flag clicked ask [What is 30 + 9?] and wait if <(answer) = > then say [Correct!] change [score v] by (1) else say [Incorrect] change [score v] by (-1) end
The Wiki is working on a dark theme, and you're seeing it! Got feedback? Post on the Wiki Forum Topic.