Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #Define the function
  2. def strToFloat():
  3. """
  4. Returns a float from string numeric entered
  5. Else asks user to enter a numeric string
  6. param: none
  7. return: float from numeric string
  8. """
  9.  
  10. x = False;
  11. while not x:
  12. try:
  13. the_str = input("Enter a any number: ")
  14. z = float(the_str)
  15. x = True;
  16. print(z)
  17. #return z
  18. except:
  19. print("Enter only numeric values")
  20.  
  21. #Call the function
  22.  
  23. strToFloat()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement