rickyjoepr rickyjoepr - 22 days ago 11
Python Question

Storing first half of string in variable

Im going through the pycharm educational edition for fun, and I am stuck on a technical error. I am trying to understand exactly what it wants. I have included a picture.

It is hinting that I need to convert the type. I have used len to count the string, which is 88, I am then printing out the first half of that string using slicing. However, it is hinting that I am missing the type conversion. Any help would be greatly appreciated, as I am curious

Link to screen -

https://drive.google.com/file/d/0B3M5poV-MbH6YnB0RF9Cb1lONlk/view?usp=sharing

Answer

You don't actually use len in your solution- your code isn't WRONG, it is just not fulfilling what it's trying to teach you. It is probably looking for something like

length = len(phrase)
first_half = phrase[0:length/2]
Comments