FAQ: Introduction to Strings - Strings and Conditionals (Part Two)


This community-built FAQ covers the “Strings and Conditionals (Part Two)” exercise from the lesson “Introduction to Strings”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

FAQs on the exercise Strings and Conditionals (Part Two)

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


How am i supposed to know from the introduction on this lesson that i can just type : return letter in word?? Also i have no idea how :

Write a function called common_letters that takes two arguments, string_one and string_two and then returns a list with all of the letters they have in common.

Is equal to:
def common_letters(string_one, string_two):
common =
for letter in string_one:
if (letter in string_two) and not (letter in common):
return common

I am so so so lost. I dont understand loops at all and now strings are killing me. I feel like I am too stupid to understand the lessons.


Did you not read the white column with the exercise-specific guide on the left? Not to mention, what you wrote works perfectly well, so I think you’re doing fine.

(Don’t mind me, I’m just here to complain about the compiler throwing TabErrors and IndentationErrors at me left and right.)


Hi, for the second part of this exercise it seems to makes no relation to string_two under the function common_letters. How is that so?
deeper explanation about the whole part 2 of this exercise is much appreciated.


We only need to iterate over one of the strings since we are not looking for uniques in each string, which would mean iterating both strings. We are looking for letters in common.

Given a letter (or character) from the one string, we use in to see if it is in the other string. If not, go to the next letter. If it does, append the letter to the return list only if it is NOT present already.


I don’t understand how not (letter in common) works in this function.

common =
for letter in string_one:
if (letter in string_two) and not (letter in common)

For example, when letter is break down as b, a,n,a,n,a in the (letter in string_one), and in the (letter in string_two), it tries to match up the letter, and will produce [a,a,a]. But I think common has a empty set, and how could it act to remove the duplicate? Or I want to say that how the variable common works in this case. Please advice.


not (letter in common) will be True if letter is not found in the common list. The same can be said of this…

 letter not in common

which does not require brackets. NOT will negate a boolean, so not True will be False, and not False will be True.


Thank you. Very helpful.


2 posts were split to a new topic: Used a brute force method; is it a bit messy?