I have the following little function written in Python:

```
def encode(str):
    out = ""
    for i in str:
        ret += str(ord(i.upper()) - 64)
    return ret

```

Basically, what I want to do is get the number of the letter in the alphabat and concatenate it to the 'out' string. With this code I get a traceback at line 4: 'str' object is not applicable. 

Could someone please explain me why it throws this error and how I can fix this? (Sorry if this was already asked once, I couldn't find it, probably also because I'm pretty new to Python and programming)