In [1]:
string = input("Enter your text here. ==>")
convBin = "" # empty variable contains binary digits
for char in string:
ordNum = ord(char) # converts each character into an ordinal
binary = bin(ordNum) # converts the ordinals into binary
binary = binary[2:] # excludes the '0b' infront of the binary
while len(binary) < 8: # adds an additional 0 in front when the binary characters are less than 8
binary = "0" + binary
convBin += binary
print(convBin)