Advertisement
AyanUpadhaya

Example of Try and Except and If else inside of if-else

Apr 7th, 2021
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. print("How many apples do you want?")
  2. apples=input()
  3. try:
  4. if int(apples)<0:
  5. print('You entered a negative number try positive')
  6. else:
  7. if int(apples)>=5:
  8. print('That are lot of apples')
  9. else:
  10. print('That is ok to eat')
  11. except ValueError:
  12. print('You did not entered a number')
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement