Page 3 of 9 FirstFirst 1234567 ... LastLast
Results 31 to 45 of 131

Thread: Any Python Programmers Out There??

  1. #31 | Top
    Join Date
    Feb 2020
    Posts
    86,918
    Thanks
    35,051
    Thanked 21,761 Times in 17,091 Posts
    Groans
    985
    Groaned 2,342 Times in 2,261 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Niche Political Commentor View Post
    ok lol I dont know why you keep ignoring me on this.

    DO. NOT. USE. "if PLst[I] == 0" Don't. STOP!

    The conditional should be "if i == 0"
    LOL. I am not ignoring. I am trying to figure out why it keep displaying the error message while a few times it doesn't.

    I wonder if it's a bug.

  2. #32 | Top
    Join Date
    Nov 2013
    Location
    internet
    Posts
    759
    Thanks
    127
    Thanked 366 Times in 247 Posts
    Groans
    5
    Groaned 24 Times in 23 Posts

    Default

    Quote Originally Posted by AProudLefty View Post
    LOL. I am not ignoring. I am trying to figure out why it keep displaying the error message while a few times it doesn't.

    I wonder if it's a bug.
    Everything has already been explained by me like 3 times in this thread by now. You'll just have to sober up until you get it. I wrote the code out above that works and does exactly what OP wants.

    Main takeaway, in a for loop if you wish to evaluate an element, you do so by doing if element = x. Not if list[element] = x. These two things are very different and will give very different results.
    Last edited by Niche Political Commentor; 12-28-2020 at 03:27 AM.
    NPC is a beloved internet personality. Their pronouns are he/him. NPC fully recognizes the inherent privilege of being able to post on a message board, and as such NPC makes sure to avoid all social media where the trust and safety council flags something as dangerous to think about. He avoids all tweets that are disputed, and only supports mainstream news sources where former CIA, NSA and FBI serve as talking heads.The future is female, orange man bad, black lives matter, and wear a damn mask!

  3. #33 | Top
    Join Date
    Feb 2020
    Posts
    86,918
    Thanks
    35,051
    Thanked 21,761 Times in 17,091 Posts
    Groans
    985
    Groaned 2,342 Times in 2,261 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Niche Political Commentor View Post
    ok lol I dont know why you keep ignoring me on this.

    DO. NOT. USE. "if PLst[I] == 0" Don't. STOP!

    The conditional should be "if i == 0"
    HOLY FUCK! I just figured it out! No bug.

    Try this.

    from random import randint
    PLst = [2, 0, 4, 5, 7, 0, 3, 2]
    Shithead = [0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0, 0]
    for I in PLst:
    Shithead[I] = randint(1,9)
    print (Shithead)

  4. #34 | Top
    Join Date
    Feb 2020
    Posts
    86,918
    Thanks
    35,051
    Thanked 21,761 Times in 17,091 Posts
    Groans
    985
    Groaned 2,342 Times in 2,261 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Niche Political Commentor View Post
    Everything has already been explained by me like 3 times in this thread by now. You'll just have to sober up until you get it. I wrote the code out above that works and does exactly what OP wants.

    Main takeaway, in a for loop you evaluate an element by doing if element = x. Not if list[element] = x. These two things are very different and will give very different results.
    I know. Both of you and I have explained. That isn't what I am talking about. What I am talking about is why the error keep appearing.

  5. #35 | Top
    Join Date
    Nov 2013
    Location
    internet
    Posts
    759
    Thanks
    127
    Thanked 366 Times in 247 Posts
    Groans
    5
    Groaned 24 Times in 23 Posts

    Default

    Quote Originally Posted by AProudLefty View Post
    I know. Both of you and I have explained. That isn't what I am talking about. What I am talking about is why the error keep appearing.
    no, your explanation was wrong. it didn't address the core issue.
    NPC is a beloved internet personality. Their pronouns are he/him. NPC fully recognizes the inherent privilege of being able to post on a message board, and as such NPC makes sure to avoid all social media where the trust and safety council flags something as dangerous to think about. He avoids all tweets that are disputed, and only supports mainstream news sources where former CIA, NSA and FBI serve as talking heads.The future is female, orange man bad, black lives matter, and wear a damn mask!

  6. #36 | Top
    Join Date
    Feb 2020
    Posts
    86,918
    Thanks
    35,051
    Thanked 21,761 Times in 17,091 Posts
    Groans
    985
    Groaned 2,342 Times in 2,261 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Niche Political Commentor View Post
    no, your explanation was wrong. it didn't address the core issue.
    As per the OP:

    "So it can't continue on and go out of range. Can it??"

    "Traceback (most recent call last):
    File "C:/Users/Sam/AppData/Local/Programs/Python/Python38/Scripts/Fourth Prac.py", line 27, in <module>
    if PLst [I] == 0:
    IndexError: list index out of range

    Totally do not understand"

    He wants to understand what the error was.

    Even after his program works (after thinking and suggestions from us), he wants to understand for future reference.

    "how can I avoid the error message."

    Debugging, assert and testing do the trick.

  7. #37 | Top
    Join Date
    Nov 2013
    Location
    internet
    Posts
    759
    Thanks
    127
    Thanked 366 Times in 247 Posts
    Groans
    5
    Groaned 24 Times in 23 Posts

    Default

    Quote Originally Posted by AProudLefty View Post
    As per the OP:

    "So it can't continue on and go out of range. Can it??"

    "Traceback (most recent call last):
    File "C:/Users/Sam/AppData/Local/Programs/Python/Python38/Scripts/Fourth Prac.py", line 27, in <module>
    if PLst [I] == 0:
    IndexError: list index out of range

    Totally do not understand"

    He wants to understand what the error was.

    Even after his program works (after thinking and suggestions from us), he wants to understand for future reference.

    "how can I avoid the error message."

    Debugging, assert and testing do the trick.
    yes and I explained it as basically as I can. his issue is wrongly trying to evaluate an element by doing if list[item] == 0
    NPC is a beloved internet personality. Their pronouns are he/him. NPC fully recognizes the inherent privilege of being able to post on a message board, and as such NPC makes sure to avoid all social media where the trust and safety council flags something as dangerous to think about. He avoids all tweets that are disputed, and only supports mainstream news sources where former CIA, NSA and FBI serve as talking heads.The future is female, orange man bad, black lives matter, and wear a damn mask!

  8. #38 | Top
    Join Date
    Feb 2020
    Posts
    86,918
    Thanks
    35,051
    Thanked 21,761 Times in 17,091 Posts
    Groans
    985
    Groaned 2,342 Times in 2,261 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Niche Political Commentor View Post
    yes and I explained it as basically as I can. his issue is wrongly trying to evaluate an element by doing if list[item] == 0
    Yeah I apologize. You and I recognize the error. Basically the 7th number is modified with randint(1,9) before it is evaluated.

    I am hoping that the OP will understand it completely. It looks like you are an experienced/professional programmer yourself.

  9. #39 | Top
    Join Date
    Feb 2020
    Posts
    86,918
    Thanks
    35,051
    Thanked 21,761 Times in 17,091 Posts
    Groans
    985
    Groaned 2,342 Times in 2,261 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Bubba View Post
    [2, _, 4, 5, 7, _, 3, 2] Underscores are actually blank boxes. Idea is to fill in the blanks with numbers 1 - 9 that make the line add up to 30. Seems to me this code SHOULD work:

    from random import randint
    PLst = [2, 0, 4, 5, 7, 0, 3, 2]
    for I in PLst:
    --- if PLst [I] == 0:
    ------- PLst [I] = randint (1, 9)
    print (PLst, sum (PLst))

    .
    0 1 2 3 4 5 6 7 index
    2 0 4 5 7 0 3 2 the list
    4 2 7 0 2 2 5 4 indices in PLst
    Do you notice the number 5?
    PLst[5] == 0. So it is modified with randint(1,9) before it is evaluated.

  10. #40 | Top
    Join Date
    Sep 2020
    Posts
    222
    Thanks
    2
    Thanked 68 Times in 58 Posts
    Groans
    0
    Groaned 2 Times in 2 Posts

    Default

    Quote Originally Posted by Primavera View Post
    Well I was going to ask him to have a look, but fuck you muchly seems more in order.
    I appreciate your response. I am, after all, the one who needs assistance.

  11. #41 | Top
    Join Date
    Sep 2020
    Posts
    222
    Thanks
    2
    Thanked 68 Times in 58 Posts
    Groans
    0
    Groaned 2 Times in 2 Posts

    Default

    Quote Originally Posted by Niche Political Commentor View Post
    yes and I explained it as basically as I can. his issue is wrongly trying to evaluate an element by doing if list[item] == 0
    OK, I do get it. (I think.) Code works now. Thank you and thanks to APL for the time you guys spent explaining it.

    Now I'm ready to move on. The original problem in the book of puzzles was an 8 X 8 grid. Each horizontal line similar to my PLst: [2, 0, 4, 5, 7, 0, 3, 2] with some of the numbers in each line missing. Those are the ones I filled in with zero.

    The challenge is to make each horizontal line AND each vertical line add to thirty. Well, I'll just type the entire puzzle.

    [2, 0, 4, 5, 7, 0, 3, 2]
    [0, 4, 1, 6, 0, 1, 9, 0]
    [4, 0, 0, 1, 0, 8, 2, 4]
    [1, 5, 0, 0, 5, 0, 0, 2]
    [0, 6, 4, 3, 0, 4, 2, 6]
    [7, 3, 4, 0, 2, 5, 1, 0]
    [0, 1, 6, 7, 1, 0, 0, 2]
    [1, 0, 2, 0, 3, 2, 5, 0]

    So all sixteen lines have to add to thirty. Now that you've pointed me in the right direction, I'm going to forge ahead and attempt to finish the puzzle.

  12. The Following 2 Users Say Thank You to Bubba For This Post:

    AProudLefty (12-28-2020), Niche Political Commentor (12-28-2020)

  13. #42 | Top
    Join Date
    Nov 2013
    Location
    internet
    Posts
    759
    Thanks
    127
    Thanked 366 Times in 247 Posts
    Groans
    5
    Groaned 24 Times in 23 Posts

    Default

    Quote Originally Posted by Bubba View Post
    OK, I do get it. (I think.) Code works now. Thank you and thanks to APL for the time you guys spent explaining it.

    Now I'm ready to move on. The original problem in the book of puzzles was an 8 X 8 grid. Each horizontal line similar to my PLst: [2, 0, 4, 5, 7, 0, 3, 2] with some of the numbers in each line missing. Those are the ones I filled in with zero.

    The challenge is to make each horizontal line AND each vertical line add to thirty. Well, I'll just type the entire puzzle.

    [2, 0, 4, 5, 7, 0, 3, 2]
    [0, 4, 1, 6, 0, 1, 9, 0]
    [4, 0, 0, 1, 0, 8, 2, 4]
    [1, 5, 0, 0, 5, 0, 0, 2]
    [0, 6, 4, 3, 0, 4, 2, 6]
    [7, 3, 4, 0, 2, 5, 1, 0]
    [0, 1, 6, 7, 1, 0, 0, 2]
    [1, 0, 2, 0, 3, 2, 5, 0]

    So all sixteen lines have to add to thirty. Now that you've pointed me in the right direction, I'm going to forge ahead and attempt to finish the puzzle.
    best of luck. let me know your progress.
    NPC is a beloved internet personality. Their pronouns are he/him. NPC fully recognizes the inherent privilege of being able to post on a message board, and as such NPC makes sure to avoid all social media where the trust and safety council flags something as dangerous to think about. He avoids all tweets that are disputed, and only supports mainstream news sources where former CIA, NSA and FBI serve as talking heads.The future is female, orange man bad, black lives matter, and wear a damn mask!

  14. #43 | Top
    Join Date
    Feb 2020
    Posts
    86,918
    Thanks
    35,051
    Thanked 21,761 Times in 17,091 Posts
    Groans
    985
    Groaned 2,342 Times in 2,261 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Bubba View Post
    OK, I do get it. (I think.) Code works now. Thank you and thanks to APL for the time you guys spent explaining it.

    Now I'm ready to move on. The original problem in the book of puzzles was an 8 X 8 grid. Each horizontal line similar to my PLst: [2, 0, 4, 5, 7, 0, 3, 2] with some of the numbers in each line missing. Those are the ones I filled in with zero.

    The challenge is to make each horizontal line AND each vertical line add to thirty. Well, I'll just type the entire puzzle.

    [2, 0, 4, 5, 7, 0, 3, 2]
    [0, 4, 1, 6, 0, 1, 9, 0]
    [4, 0, 0, 1, 0, 8, 2, 4]
    [1, 5, 0, 0, 5, 0, 0, 2]
    [0, 6, 4, 3, 0, 4, 2, 6]
    [7, 3, 4, 0, 2, 5, 1, 0]
    [0, 1, 6, 7, 1, 0, 0, 2]
    [1, 0, 2, 0, 3, 2, 5, 0]

    So all sixteen lines have to add to thirty. Now that you've pointed me in the right direction, I'm going to forge ahead and attempt to finish the puzzle.
    Have fun!

  15. #44 | Top
    Join Date
    Nov 2020
    Posts
    53,142
    Thanks
    0
    Thanked 15,989 Times in 11,516 Posts
    Groans
    873
    Groaned 2,459 Times in 2,200 Posts

    Default

    I know Monty Python.

  16. #45 | Top
    Join Date
    Feb 2020
    Posts
    86,918
    Thanks
    35,051
    Thanked 21,761 Times in 17,091 Posts
    Groans
    985
    Groaned 2,342 Times in 2,261 Posts
    Blog Entries
    1

    Default

    Now my head hurts too much to figure out how to sum the columns.

Similar Threads

  1. A Monty Python riddle for you......
    By Cancel 2020.2 in forum Off Topic Forum
    Replies: 0
    Last Post: 04-27-2020, 07:44 PM
  2. Replies: 2
    Last Post: 06-16-2018, 08:07 PM
  3. Monty Python meets Daesh
    By cancel2 2022 in forum Off Topic Forum
    Replies: 69
    Last Post: 01-13-2016, 06:00 PM
  4. 3 S.F. programmers build alternative to HealthCare.gov
    By StormX in forum Current Events Forum
    Replies: 17
    Last Post: 11-11-2013, 04:55 PM
  5. Pet Python Strangles Child, Officials Say
    By Demwit in forum Off Topic Forum
    Replies: 1
    Last Post: 07-01-2009, 07:39 PM

Bookmarks

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •