Page 1
Page 1
Started By
Message

Help needed - Simple Python question

Posted on 7/7/23 at 11:08 am
Posted by bayoubengals88
LA
Member since Sep 2007
21062 posts
Posted on 7/7/23 at 11:08 am
I'm having trouble with pop here.
I have no idea why pop() won't remove "blueberries" or why pop(2) returns 'pop index out of range' instead of simply removing "wine".

I'm sure it's terribly obvious, but I'm missing it...
Also, disregard line 13. I made a new list with a new order.

This post was edited on 7/7/23 at 11:11 am
Posted by Korkstand
Member since Nov 2003
28997 posts
Posted on 7/7/23 at 11:22 am to
You have only one set of quotes around your list items, so what you really have is a list of only 1 item.

Should look like this:
"bread", "coffee", "wine", "eggs", "turkey", "blueberries"
Posted by bayoubengals88
LA
Member since Sep 2007
21062 posts
Posted on 7/7/23 at 11:28 am to
I knew it would be something as dumb

Thanks! Now I can move on with my life
This post was edited on 7/7/23 at 12:24 pm
Posted by UltimaParadox
North Carolina
Member since Nov 2008
47238 posts
Posted on 7/7/23 at 1:45 pm to
You could try stepping through with the debugger as you learn as well. You could view the list and seen only had one member
Posted by bayoubengals88
LA
Member since Sep 2007
21062 posts
Posted on 7/7/23 at 3:27 pm to
quote:

You could try stepping through with the debugger as you learn as well. You could view the list and seen only had one member


Thanks I’ve never fooled with it. Surprised there’s not a Python or coding mega thread on this board.
Posted by Fat Batman
Gotham City, NJ
Member since Oct 2019
1555 posts
Posted on 7/7/23 at 3:57 pm to
I'd highly suggest checking out one of the many learning resource online. W3Schools, Udemy, Coursera, etc. whichever one holds your attention. I get wanting to jump in and start creating something, but its obvious you are lacking a good, or any, foundation. A good foundation will keep you from making silly errors, help you debug your own code when you do and allow you to progress faster with less frustration. The vast majority of programming is writing a few lines, running it expecting A, getting B and having to figure that shite out. For instance in your pop(2) example above its hard to figure out why the index was exceeded if you don't first know how to build a list or find its length.
This post was edited on 7/7/23 at 4:01 pm
Posted by bayoubengals88
LA
Member since Sep 2007
21062 posts
Posted on 7/7/23 at 4:18 pm to
To my knowledge I haven't jumped in and tried to create anything but yes, the urge is certainly there...

My grocery list example came from following Keith Galli on YouTube. After trying several different lectures I found him to be the best at explaining.

I am familiar with W3, Udemy, Coursera, and even have a DataCamp membership. But for beginner Python I find Keith to be the best.
He has also introduced me to codingbat.com where there are some helpful beginner level problems to solve.

In addition to that, I'm going through freeCodeCamp for Python at night as just another way to see/learn the same stuff. It's essentially a review.
I haven't tried learning anything new of this magnitude in a long, long, time. I'm having a great time. Thanks for the advice!
Posted by Fat Batman
Gotham City, NJ
Member since Oct 2019
1555 posts
Posted on 7/7/23 at 4:24 pm to
Sounds like you have a pretty good plan! Stick with it and soon enough you'll have an ah-ha moment where things just click and thats when the fun begins.
Posted by jdd48
Baton Rouge
Member since Jan 2012
22821 posts
Posted on 7/8/23 at 11:57 am to
quote:

Surprised there’s not a Python or coding mega thread on this board.


I'd be down for that.
first pageprev pagePage 1 of 1Next pagelast page
refresh

Back to top
logoFollow TigerDroppings for LSU Football News
Follow us on X, Facebook and Instagram to get the latest updates on LSU Football and Recruiting.

FacebookXInstagram