This community-built FAQ covers the “First Character” exercise from the lesson “List Comprehension”.
Paths and Courses
This exercise can be found in the following Codecademy content: Data Science
FAQs on the exercise First Character
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
I came here for help but there isn’t any for this lesson so I will post my answer and hope that someone can show me how to resolve this more efficiently: (I don’t know how to do ‘for/next’ loops yet)
I would explain this better but I’m new to Python and programming and I don’t know what any of the various elements are called. I’m also new to this forum and don’t know the proper posting standards yet.
for me matt from ohio has this all right down to a tea
[operation for item in list ] remember square brackets for example
[first_character = [name[0] for name in names]
so we replace the word “operation” with the name[0] to get all the characters in the 0 in the memory, and the word item is replaced by the whatever is stored in the variable
and names is the actual variable it is stored in i think this makes sense if not then let me know and i will try and explain it better thanks Ian
so just remember square brackets and this little sentence
[operation for item in list ]
replace the word operation with
whatever action you want to perform and the word item with number, name , string etc whatever is stored in your variable and then replace the word list with the name of the variable
in this instance it is
[operation for item in list]
instead of having above you need this
operation item list
[first_character = [name[0] for name in names]
i think this is making sense if not then let me know thanks Ian