forked from hariom20singh/python-learning-codes
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1code1020868.py
More file actions
Latest commit
35 lines (25 loc) · 653 Bytes
/
Copy path1code1020868.py
File metadata and controls
35 lines (25 loc) · 653 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Python program to check
# if a string is binary or not
# function for checking the
# string is accepted or not
defcheck(string):
# set function convert string
# into set of characters .
p=set(string)
# declare set of '0', '1' .
s= {'0', '1'}
# check set p is same as set s
# or set p contains only '0'
# or set p contains only '1'
# or not, if any one condition
# is true then string is accepted
# otherwise not .
ifs==porp== {'0'} orp== {'1'}:
print("Yes")
else:
print("No")
# driver code
if__name__=="__main__":
string="101010000111"
# function calling
check(string)