x='00101'
Given a string x consisting of only '0' and '1' with length 5 as above (the value of x is not the same as above). Just an example)
y='11010'
Write a program to find a string y whose digit values of x are converted to '0' and '1' to '0' as shown above.
python
x = '000010'
y = ''
for i in x:
y += str(int(i) ^ 1)
print (y)
It seems good to do your homework on your own.
>>> x = '00101'
>>> y = str(int('1' * len(x)) - int(x)).zfill(len(x))
>>> y
'11010'
© 2025 OneMinuteCode. All rights reserved.