I'm trying to create a program that will take a user's input, such as a URL that contains numbers, symbols, and letters and converts it into a string of binary. I've tried looking up string to binary using Python on here but so far they all seem outdated using Python 2.x instead of Python 3.x. I want it to show something like:
Enter a string to convert: http://www.google.com/ 01101000011101000111010001110000001110100010111100101111011101110111011101110111001011100110011101101111011011110110011101101100011001010010111001100011011011110110110100101111
Then stores that binary string to convert back to http://www.google.com/
I tried making a function called getInput to get user input, then returning that value to pass to another function called toBinary, but when I try to pass the returned string it gives me an error saying the argument is not defined.
Example:
def getInput():
x = input(str(Enter a string to convert: ))
return x
def toBinary(x):
#convert to binary
#print binary
return x
def toString(x)
#convert binary to string
#print string
return
getInput()
toBinary(x)
toString(x)
Thank you in advance!