Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # Author ID: zrui
- def is_digits(sobj: str) -> bool:
- # place code here - loop through each character in sobj
- # try:
- # int(sobj)
- # return True
- # except ValueError:
- # return False
- for char in sobj:
- if bool(char.isdigit())==False:
- return False;
- return True;
- if __name__ == '__main__':
- test_list = ['x1234','12x34','1234','1234x','xxxxx']
- for item in test_list:
- if is_digits(item) == True:
- print(item, ' is an integer.')
- else:
- print(item, ' is not an integer.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement