I need some help converting a string to binary. I have to do it using my own code, not built in functions (except I can use 'ord' to get the characters into decimal).
The problem I have is that it only seems to convert the first character into binary, not all of the characters of the string. For instance, if you type "hello" it will convert the h to binary but not the whole thing.
Here's what I have so far
def convertFile():
myList = []
myList2 = []
flag = True
string = input("input a string: ")
for x in string:
x = ord(x)
myList.append(x)
print(myList)
for i in range(len(myList)):
for x in myList:
print(x)
quotient = x / 2
quotient = int(quotient)
print(quotient)
remainder = x % 2
remainder = int(remainder)
print(remainder)
myList2.append(remainder)
print(myList2)
if int(quotient) < 1:
pass
else:
x = quotient
myList2.reverse()
print ("" .join(map(str, myList2)))
convertFile()