Why does my code print “built-in method” and some hex numbers?

Here is my Key function:

def Key(message, decision):
    key = input("Input the key which will be used to encode the message.n".lower)
    n = 0
    for i in range(len(key)):
        if 64 < ord(key[n]) < 91:
            raise ValueError(key[n], "is a capital letter!")
        else:
            n = n+1
    Keycode(decision, message, key)

When I call it and input the message and press enter it comes up with:

built-in method lower of str object at 0x0150E0D0

What’s wrong? How can I fix it?

Answer

Key contains this problematic line:

key = input("Now, input the key which will be used to encode the message.n".lower)

which passes as input to input the lower method of a string, when you (presumably) want to pass the string and then apply lower to what input returns.

Leave a Reply

Your email address will not be published. Required fields are marked *