Python strings - general


#1



Replace this line with your code.


#2

Just started to use CA. Its nice but it doesn't explain why.
Example:
why len is like this: len(string)
and lower() is like this: string.lower()


#3

Hi, @at_1965 ,

len is a Python built in function that can be used with several different types of objects, including lists and strings. To use the function, we pass it an argument enclosed within parentheses.

In contrast, lower is a method that defined as part of the str type, which represents strings. To call a method, we typically use dot notation, which consists of an object, followed by a dot, followed by the name of the method, and finally by parentheses, containing any arguments, if any, to be passed to the method. This concept will become clearer in later Python exercises, especially the ones focusing on classes.


#4

Hi @appylype

I'm still new to Code academy, so please forgive me if this is not the place for my question.
I just would like to know the difference in placing a string between a single quotation mark, and a double quotation mark in Python. When would we need to use the one or the other.

Thank you [ :


#5

Hi, @netrunner10450 ,

Strings delimited by single or double quotes around it are equivalent, if they have the same content. But, after completing Exercise 3: Escaping characters, consider the various choices you have for creating a string that contains either double or single quotes inside it.


#6

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