Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_float(text_input, text_error, min_val):
- while True:
- try:
- value = float(input(text_input))
- if value >= min_val:
- return value
- print(text_error)
- except ValueError:
- print('You have to enter float number')
- except KeyboardInterrupt:
- print("You can't exit now.")
- def get_int(text_input, text_error, min_val):
- while True:
- try:
- value = int(input(text_input))
- if value >= min_val:
- return value
- print(text_error)
- except ValueError:
- print('You have to enter integer number')
- except KeyboardInterrupt:
- print("You can't exit now.")
- flour = get_int('Flour: ', 'Flour must not be less than 50kg', 50)
- print('value:', flour)
- flour = get_float('Flour: ', 'Flour must not be less than 50kg', 50)
- print('value:', flour)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement