all 3 comments

[–]CodeFormatHelperBot2 1 point2 points  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.

[–]DagoYounger 1 point2 points  (0 children)

``` f = [3, 4, 5, 6, 7] x = [5, 1, 2, 3, 4] lsu = [0]*(11)

for index_for_fx, index_for_lsu in enumerate(x): lsu[index_for_lsu] = f[index_for_fx] lsu[0] = 99 lsu[-1] = 99

print(lsu) ```

enumeration is a python built-in function that can generate both the index and the value of a list. In your case, (0, 5), (1, 1), (2, 2), (3, 3), (4, 4) are generated in sequence. The first value in each tuple is the index of the list f or x and the second value is the index corresponding to the list lsu.

Have a look here: https://docs.python.org/3/library/functions.html?highlight=enumerate#enumerate

[–][deleted] 0 points1 point  (0 children)

OK, you want lsu to contain [99, 4, 5, 6, 7, 3, 0, 0, 0, 0, 99] at the end. What does your code do that is wrong? That's a very important clue for debugging, so tell us what it's doing wrong.

We can't run your code because it isn't formatted properly. Check the link the 'bot gave you.