+ 3
Can anyone suggest me?
I didn't find any other way to flip the boolean numbers...can anyone suggest me any other way to flip the boolean?? In Python only.👍 https://code.sololearn.com/cNiu3j4Lq2pj/?ref=app
4 odpowiedzi
+ 3
a=input("Enter a boolean number:")
print("the swapped boolean is:")
for i in list(a):
print (int(not bool(int(i))))
+ 8
You can use regex to check the entire string for values other than 1 and 0, prior to iterating the string.
+ 7
a=input("Enter a boolean number:")
print(a)
print("the swapped boolean is:")
for i in a:
if i =="1" or i == "0":
print(0 if i == "1" else 1, end='')
else:
print("Give valid input")
+ 2
@Hasty rei , I think you're sarcastic boy..I too did same thing bro....I need another logic..😁