[Tutor] Pycharm Edu Lesson 3, Task 7

Alan Gauld alan.gauld at yahoo.co.uk
Tue May 2 04:27:56 EDT 2017


On 02/05/17 01:42, David Wolfe wrote:

> I'm working through Pycharm Edu, and I'm stuck on the following:
> 
> phrase = """
> It is a really long string
> triple-quoted strings are used
> to define multi-line strings
> """
> first_half = phrase[:len(phrase)//2]
> print(first_half)
> 
> 
> The instructions are:
> The len() function is used to count how many characters a string contains.
> 
> Get the first half of the string stored in the variable phrase.
> Note: Remember about type conversion.

I'm assuming this is only part of the story since the instructions don't
make sense. There is no need for type conversion here.

> and my output is:
> 
> It is a really long string
> triple-quoted st
> 
> which is what I'm supposed to get, but I keep getting the error message
> "Too short string in the output"

I don't know the PyCharm IDE but is that all it says?
I'd expect a bit more information about where the error lies.
It certainly isn't obvious and I don't get any such error when
I execute your code in IDLE.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list