Why doesn’t parrot have quotes around it when being printed?



Why doesn’t parrot have quotes around it when being printed?


While it wouldn’t be invalid to type len("parrot"), it would not be equivalent to len(parrot). To print a variable, we don’t wrap it in quotes, we just write the name of the variable, and it provides whatever is contained inside of it to the len( ) method. The difference would be “parrot” instead of "Norwegian Blue".
For a better understanding, check out the code below:

my_bird = "penguin"
print my_bird   # prints “penguin” to the screen
print "my_bird"   # prints “my_bird” to the screen

FAQ: Learn Python – Strings & Console Output – String Methods
>>> my_bird = "penguin"
>>> print (my_bird)
>>> print ("my_bird")

Note that quotes are not printed unless they are intentionally printable characters.

>>> my_bird = '"penguin"'
>>> print (my_bird)
>>> print ("\"my_bird\"")


Hello everybody.
I have not understood yet, the number 14 when I put print len(parrot)


the number 14 is the number of characters in the text “Norwegian Blue”. That is the length of the text


ooooooooohhh thanks a lot


Hello. I do not understand how 14 is the len of “Norwegian Blue”. When I count the text starting at N = 0 I am coming up with 12 not including the space between the words. Are the quotations included in the len?


The length is the a count of all the characters in the string, including spaces. len() is a natural number so starts from 1.

The first character is at index 0. Not to be confused with character count. It counts as 1.

Quotes are not part of the character count since they are string delimiters. Only count the characters between the quotes.