<Want to know about the string methods>


#1

STRINGS & CONSOLE OUTPUT
String methods
Link=>https://www.codecademy.com/courses/learn-python/lessons/strings--console-output/exercises/string-methods?action=lesson_resume&link_content_target=interstitial_undefined

MY CODE=>parrot = "Norwegian Blue"
print len(parrot
RESULT = 14

But why is the result is 14 instead of 13 as the “Norwegian Blue” as 13 charachters
Is it also counting up the spaces between the two words?
HERE’S ANOTHER PROBLEM>

The code runs well in the the codecademy but in the original PYTHON (its IDLE) it shows an error
parrot = "Norwegian Blue"
print len(parrot)
SyntaxError: multiple statements found while compiling a single statement

Please tell me how resolve this problem
Thanks


#2

spaces is part of the string, so its counted. All characters within the string are counted

I ran your code, no problem. Can you show a screenshot of the lesson (code, output and error), so pretty much the entire screen


#3


Thanks for the answer
Here is your Screenshot as requested:)


#4

the lessons use a python file/script, you use the python IDLE. In the idle, you need to enter one line at a time:

Screenshot_2017-11-22_17-51-17

okay, we still get a syntax error, but its getting better. Just like me, you are python3, in python3, print is no longer a statement, its a function call so it requires parentheses:

print(len(parrot))

#5

Hey man thanks for that it just resolved my problem:)
Have a nice day


#6

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