Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Logic in Python Loop

i tried the .append method and reviewing the video twice but did not see this covered.

i tried the .append method and reviewing the video twice but did not see this covered. Would my code or the .append method both not work? Didn't see this covered in the preceding video

hellos = [
    "dobrý den",
    "hyvää päivää",
for hellos
    print(hellos) ("world")

2 Answers

Hey Daniel! Couple of things here. One is that your not creating the for loop properly, a for loop should look like this:

for ITEM in VARIABLE: # Here were looping thru a variable, and in each iteration where saving whatever is in that current position to the varibale "ITEM". 
    # Do something

Second is you should try to concatenate whatever the variable "ITEM" currently stores with the string "world". This can be done with the + operator. So your code should look like this:

for i in hellos:
    print(i + " world") # Remember to add a space at the start of the string, since we dont want to display the two words as one

Hope this helps! Note. If you look at the very first thing he explains in the previous video, you will find the solution to this challenge. I recommend rewatching it!

venkat bogadi
venkat bogadi
1,031 Points

hope below code helps

item_list=[] for items in hellos: item_list.append(items) print(item_list)

This code is not a valid solution for this challenge.