For some reason the line "new1 = [chr(x) for x in new]" cannot take a float. I am converting all the ASCII integers in the 'new' list back to a list with characters, according to their respective ASCII number, this list would be saved as new1.
if de == "d":
num = input("input ur number: ")
key = int(input("Decryption key?"))
num = [int(x) for x in num.split()]
new = [x /key for x in num]
new1 = [chr(x) for x in new]
This is the error:
--Traceback (most recent call last): File "C:\Python34\Encryptiontrue.py", line 23, in new1 = [chr(x) for x in new]
-- File "C:\Python34\Encryptiontrue.py", line 23, in new1 = [chr(x) for x in new]
-- TypeError: integer argument expected, got float
Full Code:
de = input("Decrypt or encrypt?: ")
if de == "e":
word = input("input ur text: ")
word = word.lower()
new = list(word)
key = int(input("what number by?: "))
new1 = [ord(x) * user for x in new]
new2 = " ".join(str(x) for x in new1)
print(new2)
if de == "d":
num = input("input ur number: ")
key = int(input("Decryption key?"))
num = [int(x) for x in num.split()]
new = [x /key for x in num]
new1 = [chr(x) for x in new]
chr(x)shouldn't take a float because how would you convert something like26.23into a ascii character? do an explicit integer conversion in your list comprehension fornewwithx//keyorint(x/key).