subject

This is my code and i cant find what the problem is could you help me #!/usr/bin/env python
# coding: utf-8

# In[2]:

while True: # Program will keep running until we quit it ourselves , Infinite loop
print("\n\n BINARY / DECIMAL CONVERSION \n\n") # Title
choice = input("1- Binary to Decimal conversion \n2- Decimal to Binary Conversion \n3- Quit \n\n =>") #Menu

if choice == "1": # binary to decimal
binary = (list(input("\n\nInput a binary number: "))) #input binary number and covert it into list
decimal = 0 #this variable will hold final decimal converted value
i = 0
binary = (list(input("\n\nInput a binary number: ")))
digit = binary. pop() # pop is a method of list which removes and return last item of list
for i in range(len(binary)): #Loop number of digits of binary number time

if digit == '1': #if digit is one , add 2 raised to the power i to the decimal variable

decimal = decimal + pow(2, i)
print("The decimal value of the number is: ", decimal) #print result

if choice =="2":#decimal to binary

decimal = int(input("\n\nInput a Decimal Number: ")) #input decimal number and convert it into integer
i = 0
binary = [] # this list will hold final binary result
while decimal!=0: # while decimal value is not equal to zero
rem = decimal%2 #remainder of decimal divided by 2
binary. insert(i, rem) #insert remainder on ith index of binary list
i = i+1
decimal = int(decimal/2) #dividing list by 2

i = i-1
print("\nThe Binary value of the number is:")
binary. reverse() # We need to reverse the list to get the result we want

for i in range(len(binary)):
print (binary[i],end ="") #printing each index of binary list one by one

if choice == "3":#Quit
print("\n\n Program Terminated Successfully ")
exit() #Terminates the program

# In[ ]:

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:20
What does a bonus object do? a. subtracts lives b. keeps track of a player's health c. gives a player an advantage d. makes text appear
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
question
Computers and Technology, 23.06.2019 21:40
language consists of basic components, and they are called a. 3; mental images, concepts, and speech b. 2; language acquisition and linguistic relativity c. 3; heuristics, algorithms, and analogies d. 4; phonemes, morphemes, syntax, and semantics e. 2; words and grammar
Answers: 3
question
Computers and Technology, 24.06.2019 02:00
Which steps will open the system so that you can enter a question and do a search for
Answers: 1
You know the right answer?
This is my code and i cant find what the problem is could you help me #!/usr/bin/env python
...
Questions
question
English, 20.10.2020 06:01
question
English, 20.10.2020 06:01
question
Business, 20.10.2020 06:01
Questions on the website: 13722362