How to use 'how to take float input in python' in Python

Every line of 'how to take float input in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
29def input_float(prompt=''):
30 """Ask for a human float input.
32 Args:
33 prompt (string): Text to prompt as input.
34 """
35 # try:
36 # return raw_input(prompt)
37 # except NameError:
38 # return input(prompt)
40 while True:
41 try:
42 float_input = float(input(prompt))
43 except ValueError:
44 print('Please enter a float.\n')
45 continue
46 else:
47 break
48 return float_input

Related snippets