Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Define the function
- def strToFloat():
- """
- Returns a float from string numeric entered
- Else asks user to enter a numeric string
- param: none
- return: float from numeric string
- """
- x = False;
- while not x:
- try:
- the_str = input("Enter a any number: ")
- z = float(the_str)
- x = True;
- print(z)
- #return z
- except:
- print("Enter only numeric values")
- #Call the function
- strToFloat()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement