+ 2
Why does my code have error ??
Hi can you tell me why is my this code isn't working?? # Input 0 for binary to int or 1 for int to binary # Then input your number a = int(input ()) if a == 0: b = bin (input ()) b = str (int (b)) print (b[2:-1], b[-1]) elif a == 1: c = int (input ()) c = str (bin (b)) print (c[2:-1], c[-1]) https://code.sololearn.com/cRDPMj5naXcy/?ref=app
2 Réponses
+ 4
the code can be done a bit shorter, also there are some issues:
a = int (input ())
if a == 0:
print(int(input(),2))
elif a == 1:
print(bin(int(input()))[2:])
0
In 6 line use bin(int(input()))