WillRegex@lemm.ee 1 year ago
I think you’re misunderstanding the insert
method. insert
keeps everything that was already in the list, including the item at the given index. it just shifts part of it to the right to make room for the thing you’re inserting. Directly changing the list using display[position] = letter
instead replaces the item at the index with letter
.
Does that make sense?
Osnapitsjoey@lemmy.one 1 year ago
Yeah I figured that one out from the documentation. I with I saved more of my trial and errors so I could show you guys what I needed help with better. I tried the list.insert(x) and then I would do a list.pop(i+1) as well 😂
I guess what I need help with is I keep messing up where I would put "for x in y: z= y [in position z]
potterman28wxcv@beehaw.org 1 year ago
Instead of blindly trying code until it works I would suggest you to write on paper the distinct steps that are required to solve the problem.
Imagine you are the computer and you can do nothing else but what Python allows you. How do you solve the problem ?
Usually people do this exercise on a small example. Then they generalise the approach when they find examples where it does not work.
Osnapitsjoey@lemmy.one 1 year ago
Ahhh you know what. This would help me. Because when I’m stumped, I’m definitely just “blindly” trying different orders of things and getting frustrated. Thank you very much for the tip
potterman28wxcv@beehaw.org 1 year ago
Yeah sometimes you just have to take a step back and think again. Then you will think more clearly and actually know what you wrote :) good luck!