Quotes help make search much faster. Example: "Practice Makes Perfect"

Saturday, December 8, 2012

LearnStreet Python Lesson 3 Exercise 11


//sample solution

Allergic to Peanuts?
Let's combine a few concepts you've learned in this lesson so far for this last exercise.

You have a recipe book stored as a string in the variable book, and you want to see if the first half of the book contains the word "peanut". Check if the first half of the string stored in book contains the string "peanut".

"peanut" in book[0:len(book)/2]
=> True
Don't eat this if you're allergic to peanuts! Congratulations on completing your third Python lesson!

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts