Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import re
- def convert_binary_to_int(b):
- return int(b,2)
- while True:
- user_input= input("enter a binary form string : ")
- if bool(re.match(r"\b[01]+\b",user_input)):
- print("the conversion result is : " + str(convert_binary_to_int(user_input)))
- break
- else:
- print("Only a binary string form '0' and '1' is accepted!")
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement