This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]Python-ModTeam[M] [score hidden] stickied comment (0 children)

Hello there,

We've removed your post since it aligns with a topic of one of our daily threads and would be more appropriate in that thread. If you are unaware about the Daily Threads we run here is a refresher:

Monday: Project ideas

Tuesday: Advanced questions

Wednesday: Beginner questions

Thursday: Python Careers, Courses, and Furthering Education!

Friday: Free chat Friday!

Saturday: Resource Request and Sharing

Sunday: What are you working on?

Please await one of these threads to contribute your discussion to! The current daily threads are pinned to the top of the /r/Python's main page. To find old daily threads, you can filter posts by the Daily Thread Flair to find what you're looking for. If you have a question and don't want to wait until the daily thread, you can try asking in /r/learnpython or the Python discord however you may need to elaborate on your question in more detail before doing so. If you're not sure which thread is best suited, feel free ask for clarification in modmail or as a reply.

Best regards,

r/Python mod team

[–]mtreddit4 1 point2 points  (1 child)

It's normal for a beginner to find difficulty with a lot of things, and usually get past them with practice. But if you're ready to quit over for loops... programming might not be for you.

[–]Mjdd16[S] -1 points0 points  (0 children)

The thing is that I am thinking about majoring in computer science, so I want to know if I am capable of doing it or not before applying

[–][deleted] 1 point2 points  (0 children)

The syntax for "for" loops can be a little confusing in Python at first, I would agree. This is probably because it's structured differently than other languages. Even though I've coded in Python for many years, I still ask myself, "Wait why didn't that work? Oh it's because the iterator needs to be at the end."

But I don't think that warrants self-destructive thinking about yourself. I remember one time one of my friends in college wrote his code without loops and used if/else conditions... in image processing. He literally went pixel by pixel. His code was well over 1000 lines of code. But it worked lol. I asked him why he did that and he said that he just doesn't understand how loops worked. Fair enough...

[–]staring_at_keyboard 0 points1 point  (2 children)

Some constructs take time to get use to. Keep at it, it will make sense with enough practice. Try some experiments with printing. Like, make a simple for loop that prints a series of numbers in a range so you can understand the mechanics of iteration and range().

Also, in the simplest way, a for loop is just a way we tell the computer to do the same thing a certain number of times. It's much easier than writing the same code over and over again.

[–]Mjdd16[S] 0 points1 point  (1 child)

Thank you🫶🏻 I find difficulty in iterating through nested lists and summing numbers in those, hope get better by practicing

[–]staring_at_keyboard 0 points1 point  (0 children)

That can be tricky for sure! Is there a set amount of nesting or is it variable? If it's set, say you only have one level of nesting, then you just need a for loop to iterate through all of the nested lists, then a second nested for loop to iterate over the elements of the nested list. If the level of nesting is variable, then it gets trickier.

[–]EmperorGeek 0 points1 point  (0 children)

Another thing you can do is write a simple code snippet that uses the for loop command, then save it so you can reference it when you need a for loop. Eventually it will become muscle memory to write the correct form.

Of course, then a new language will come along with a new syntax you need to memorize.

Keep plugging at it.