#1

I don't know how i can append multiple strings at once

``````start_list = [5, 3, 1, 2, 4]
square_list = []

for square_list in start_list:
return star_list.append(0, 5**2)

print square_list``````

#2

The code inside the loop `for item in start_list` would occur 5 times because it's iterating through `start_list` which contains 5 items. The `.append()` method takes one argument and adds it to the end of the list. So it's okay that you only perform one action because as the `for` loop runs, that one action will be performed 5 times.

#3

It would make more sense to use `for item in start_list` because `item` is your location in the list `start_list` during each round of the loop.

On your return line, `.append()` only takes one argument. You want to take the current `item` and square `** 2` it then `append()` the result to `square_list`. There's no need to `return` the value because you're not in a function.

#4

Thanks for the directions. Can you go further and give me at least the frame of how I can write my code on this stage? I am not able to implement what you told me...

#5

I've been told that I can't just type out correct code for you to copy/paste because that's like cheating. So here's working code for a different scenario - converting temperature from Celsius to Fahrenheit. If you understand this code (especially by running it to see how it works), you should be able to use the same setup, making a few key changes, to pass this exercise.

``````celsius_list = [50, 30, 10, 20, 40]
fahrenheit_list = []

# loop through each item in the celsius list
for item in celsius_list:

# perform conversion (F = C * 9 / 5 + 32)
# append result to new list
fahrenheit_list.append(item * 9 / 5 + 32)

# see the list as it is built each loop
# just for visual feedback in the console
print fahrenheit_list

# see the complete list after looping
print fahrenheit_list``````

#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.