Re: python adds an extra half space when reading froma string orlist -- back to the question

Discussion in 'Python' started by Dave Angel, Jul 1, 2013.

  1. Dave Angel

    Dave Angel Guest

    On 07/01/2013 03:32 PM, Joel Goldstick wrote:
    > I copied the original question so that the rant on the other thread
    > can continue. Let's keep this thread ontopic
    >
    >
    > number_drawn=()
    > def load(lot_number,number_drawn):
    > first=input("enter first lot: ")
    > last=input("enter last lot: ")
    > for lot_number in range(first,last):
    > line_out=str(lot_number)
    > for count in range(1,5):
    > number_drawn=raw_input("number: ")
    > line_out=line_out+(number_drawn)
    > print line_out
    > finale_line.append(line_out)
    > finale_line2=finale_line
    >
    > load(lot_number,number_drawn)
    >
    >
    > print finale_line
    > print(" "*4),
    > for n in range(1,41):
    > print n, #this is to produce a line of numbers to compare to
    > output#
    > for a in finale_line:
    > print"\n",
    > print a[0]," ",
    > space_count=1
    > for b in range(1,5):
    > if int(a)<10:
    > print(" "*(int(a)-space_count)),int(a),
    > space_count=int(a)
    > else:
    > print(" "*(a-space_count)),a,
    > space_count=a+1
    >
    >
    >
    >
    >
    >
    >
    >
    >


    <Duplicate code removed>

    >
    >
    >
    > this generates
    > <type 'list'>
    > enter first lot: 1
    > enter last lot: 4
    > number: 2
    > number: 3
    > number: 4
    > number: 5
    > 12345
    > number: 1
    > number: 2
    > number: 3
    > number: 4
    > 21234
    > number: 3
    > number: 4
    > number: 5
    > number: 6
    > 33456
    > ['12345', '21234', '33456']
    > 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    > 27 28 29 30 31 32 33 34 35 36 37 38 39 40
    > 1 2 3 4 5
    > 2 1 2 3 4
    > 3 3 4 5 6
    >> #as you can see many numbers are between the lines of a normal print#

    > #I thought this was due to "white space" int he format .So I tried a list
    > of strings and got the same results.#
    >


    But what was the expected output? And who cares? The code made no
    sense, was incomplete, and the posted question was nonsensical.

    If the OP has abandoned it, so should we.

    --
    DaveA
     
    Dave Angel, Jul 1, 2013
    #1
    1. Advertising

  2. Dave Angel

    rusi Guest

    Re: python adds an extra half space when reading froma string or list-- back to the question

    On Tuesday, July 2, 2013 1:32:44 AM UTC+5:30, Dave Angel wrote:
    > But what was the expected output? And who cares? The code made no
    > sense, was incomplete, and the posted question was nonsensical.


    Yes in this specific instance all this is probably true.
    I believe however, that Joel's intent in reposting this is more global (and important) in its scope, viz:

    If this list persists in the current unhealthy state which it is experiencing, authentic noob questions will get buried in mountains of bullshit.

    Note: I find Joshua's answer fine given the question.

    > If the OP has abandoned it, so should we.


    If you were a noob-OP who asked that question and the result unfolded as it has, what would you do?
     
    rusi, Jul 1, 2013
    #2
    1. Advertising

  3. Dave Angel

    Dave Angel Guest

    On 07/01/2013 05:16 PM, rusi wrote:
    > On Tuesday, July 2, 2013 1:32:44 AM UTC+5:30, Dave Angel wrote:
    >> <SNIP>


    >
    > Yes in this specific instance all this is probably true.
    > I believe however, that Joel's intent in reposting this is more global (and important) in its scope, viz:
    >
    > If this list persists in the current unhealthy state which it is experiencing, authentic noob questions will get buried in mountains of bullshit.
    >
    > Note: I find Joshua's answer fine given the question.
    >
    >> If the OP has abandoned it, so should we.

    >
    > If you were a noob-OP who asked that question and the result unfolded as it has, what would you do?
    >


    Point well-taken. So I'll see what I can do here. I'll put comments on
    lines I had to add or change.


    finale_line = [] #missing initialization
    lot_number = 99

    number_drawn=()
    def load(lot_number,number_drawn):
    first=input("enter first lot: ")
    last=input("enter last lot: ")
    for lot_number in range(first,last):
    line_out=str(lot_number)
    for count in range(1,5):
    number_drawn=raw_input("number: ")
    line_out=line_out+(number_drawn)
    print line_out
    finale_line.append(line_out)

    #finale_line2=finale_line #not referenced

    load(lot_number,number_drawn)


    print finale_line
    print(" "*4),
    for n in range(1,41):
    print n, #this is to produce a line of numbers to
    #compare to output#
    for a in finale_line:
    print"\n",
    print a[0]," ",
    space_count=1
    for b in range(1,5):
    if int(a)<10:
    print(" "*(int(a)-space_count)),int(a),
    space_count=int(a)
    else:
    pass
    #print(" "*(a-space_count)),a, #dead code
    #space_count=a+1 #dead code

    Since all the numbers are butted together in the string line_out, the
    later logic is iterating over digits, which cannot be bigger than 9. So
    the else clause is nonsensical. Even if they were to run, they'd give
    runtime errors.

    > #as you can see many numbers are between the lines of a normal print#
    > #I thought this was due to "white space" int he format .So I tried a
    > list
    > of strings and got the same results.#


    No clue what that means. What numbers are between what lines? And what
    is a normal print?

    Presumably the intent was to somehow do a variable spacing of those digits.


    --
    DaveA
     
    Dave Angel, Jul 2, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christoph Haas
    Replies:
    4
    Views:
    338
    Christoph Haas
    Oct 2, 2005
  2. Joshua Landau
    Replies:
    0
    Views:
    124
    Joshua Landau
    Jun 29, 2013
  3. Mark Lawrence
    Replies:
    106
    Views:
    780
    Antoon Pardon
    Jul 8, 2013
  4. Joshua Landau
    Replies:
    0
    Views:
    126
    Joshua Landau
    Jun 29, 2013
  5. Joel Goldstick
    Replies:
    1
    Views:
    104
    alex23
    Jul 2, 2013
Loading...

Share This Page