Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # Author ID: zrui
  3.  
  4. def is_digits(sobj: str) -> bool:
  5. # place code here - loop through each character in sobj
  6. # try:
  7. # int(sobj)
  8. # return True
  9. # except ValueError:
  10. # return False
  11. for char in sobj:
  12. if bool(char.isdigit())==False:
  13. return False;
  14. return True;
  15.  
  16. if __name__ == '__main__':
  17. test_list = ['x1234','12x34','1234','1234x','xxxxx']
  18. for item in test_list:
  19. if is_digits(item) == True:
  20. print(item, ' is an integer.')
  21. else:
  22. print(item, ' is not an integer.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement