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

Juan Llano
seal-mask
.a{fill-rule:evenodd;}techdegree
Juan Llano
Full Stack JavaScript Techdegree Student 481 Points

I don't understand how to deduce this question? Can someone please explain it to me in a step by step manner? Thank you.

I was thrown off by the if statement inside the for loop. I am unable to deduce this problem. Please help!

1 Answer

Hai Phan
Hai Phan
2,442 Points

Since for loop check every single letter in order, the if statement is the condition to executive the print() function. I can say these steps like this, you split this string into single character "Y/o/u/ /g/o/t/ /t/h/i/s", then you check every letter from left to right, if it matches the condition (in "oh" or not), print out the letter. Hope this help.