Stuck on 6, lower()

I’ve been trying to make the Parrot, lowercase but i keep getting an error

If you want to lowercase the string “Parrot”, then write:
and if you want to lowercase the variable, which has the string, then write:
->or whatever your variablename is

1 Like

what is the logic here? why not * print lower(parrot) * is not a valid function?

The function is string.lower(), not lower(string)

you should write parrot.lower()

It will work surely!

Length is len(string), not string.len(). What’s the story there? I guess it’s len(string) in the very previous assignment that makes people expect lower(string) here.

what’s the different between “parrot”.lower() and parrot.lower().
p/s i tried “parrot”.lower(), i got error with this but it’s work with parrot.lower().
I want to know why, please explain, thank you very much.

Hi Guys!
“Norwegian Blue”.lower() will work as well :wink:

Agree with gwaur… Would like to know why the methods differ ( len(string) vs string.lower() ).

I had the same question. Turns out it’s explained two lessons later: "Methods that use dot notation only work with strings.

On the other hand, len() and str() can work on other data types."

1 Like

it didnt work and i tried every thing leas help

me too? i printed parrot.lower() with no success.

Hello, everyone,

To pass this exercise, you must first assign "Norwegian Blue" to parrot. That assignment is given in the default code. Then make the following call to the lower method …

print parrot.lower()

The question has been raised regarding why we do this when we call len

print len(parrot)

… but use this contrasting syntax when we want to see the value of parrot in lowercase …

print parrot.lower()

First of all, there is a problem with the use of terminology in Exercise 5: String methods. Despite the fact that the background information in that exercise lists len as a “string method”, it is a function, and should not be referred to as a method.

A method is a function that is part of the definition of a particular type, but len is defined externally to any type, and therefore is not part of the definition of the str type that represent strings.

In contrast, lower is a function that has been defined as part of the definition of the str type. We can refer to a function that is defined as part of a specific type as a method. Therefore, lower fits that definition of a method, while len does not.

To call a function, specify the name of the function, followed by parentheses. If that function needs to passed any arguments, place those arguments inside the parentheses, for example …

print len(parrot)

To call a method, use dot notation. This consists of specifying the object on which the method is being called, followed by a dot, followed by the name of the method, followed by parentheses. If arguments need to be passed to the method, place them within the parentheses. This method call follows that syntax …

print parrot.lower()

In the above case, the lower method is not being passed any arguments, so the parentheses are empty.

In later parts of the Python track, you will be creating functions, and still later, methods. In those exercises, the distinction between a function that is not a method and one that is a method will become more obvious. In the meantime, use the information that you are given in the exercises to make the distinction.

You can also learn more by browsing through the official Python web site. There’s lots of information there, including documentation on …

1 Like