String Method format


#1



https://www.codecademy.com/en/courses/python-beginner-sRXwR/1/2?curriculum_id=4f89dab3d788890003000096


The lesson before this prints the length of parrot with the following code:

print len(parrot) = 14


The code below shows the method name, then 'dot' then the variable name, finally open and close parentheses.
How to know if the format on how to use a method is like the code above or the code below?

Thanks!

parrot = "Norwegian Blue"

print lower.parrot()


#2

Don't worry there is lesson about it Dot Notation

from lesson:

Methods that use dot notation only work with strings.

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


#3

Oh is that so? Super thanks Sir!


#4

it should be:

variableName.methodName()

you seemed to have swapped the variable and method name.

That is the tricky question, the problem is that both function and classes haven't been covered yet. For know, i am afraid you will just have to remember (write it down)

I could explain the difference, but i am afraid this will be only be more confusing for the moment.

Once you learned a bit about function, we can come back to this issue?


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.