User input/Text: Difference between revisions

Added Quackery.
m (→‎{{header|Plain English}}: trim whitespace, change capitalization)
(Added Quackery.)
Line 1,812:
<lang python> number = float(input("Input a number: "))</lang>
float may be replaced by any numeric type, such as int, complex, or decimal.Decimal. Each one varies in expected input.
 
=={{header|Quackery}}==
 
The word $->n attempts to convert a string to an integer, and returns an integer and a success flag. Validating the input is not part of the task, but since the flag is there we might as well use it. Similarly, might as well trim leading and trailing spaces, because ''users'', eh.
 
<lang Quackery>$ "Please enter a string: " input
say 'You entered: "' echo$ say '"' cr cr
$ "Please enter an integer: " input
trim reverse trim reverse
$->n iff
[ say "You entered: " echo cr ]
else
[ say "That was not an integer." cr
drop ]</lang>
 
{{out}}
 
<pre>Please enter a string: 3-ply sisal twine
You entered: "3-ply sisal twine"
 
Please enter an integer: 75000
You entered: 75000
</pre>
 
=={{header|R}}==
1,462

edits