[Tutor] Anyone fancy giving me some tips and an expert opinion??
kent37 at tds.net
Fri Feb 8 03:15:50 CET 2008
Damian Archer wrote:
> # User inputs numbers to compare, z is for the index counter
> x = input("Enter a number between 1 and 0: ")
> y = input("Enter a second number between 1 and 0: ")
We generally discourage the use of input(), it is (arguably) a security
and a rather contentious discussion on this very list -
- and it doesn't validate the input. A better way to write this would be
x = float(raw_input("Enter a number between 1 and 0: "))
y = float(raw_input("Enter a second number between 1 and 0: "))
which is safer and guarantees that x and y are floating point numbers.
More information about the Tutor