Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Functions and Looping For Looping

Soham Haryani
Soham Haryani
262 Points

Explanation of code

for letter in "You got this!": if letter in "oh": print(letter) I am not getting this code

1 Answer

For each element in the string "You got this!", eg: Y, o, u, space, g, o, t, space, t, h, i, s, ! do the following: if the element is present in the string "oh", then print it out.

Another way of thinking about it, is if the string "oh" includes the current element being iterated, then print it out.