Reputation: 115
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?
Upvotes: 7
Views: 87673
Reputation: 1
.lower() method is a method of the str class. .lower() converts the string to lowercase. in order To call the lower() method you need to write the name of the method(.lower or .upper), followed by parentheses().
Upvotes: 0
Reputation: 557
key = input("Input the key which will be used to encode the message.\n".lower)
Because lower function is missing parenthesis, put parenthesis after function call. so syntax would be like
key = input("Input the key which will be used to encode the message.\n".lower())
Upvotes: 1
Reputation: 331
You need to use closed pair of parenthesis after lower
key = input("Input the key which will be used to encode the message.\n".lower())
Upvotes: 3
Reputation: 181
After .upper
or .lower
there has to be a closed pair of parentheses. You can put custom arguments in them but if you just want to capitalize the input leave them empty.
Example:
user=(input("Enter a letter:")).upper()
This will change case to upper.
Upvotes: 18
Reputation: 49893
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.
Upvotes: 1
Reputation: 1
Try saving your work in your work space. If you're using the Python prompt to check your results, use the exit()
command and open a Python prompt again. Then try calling the previous functions as you were doing earlier on.
Upvotes: -4