Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.107 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.79; '*S*': 0.01; 'else:': 0.03; '")': 0.09; '8bit%:78': 0.09; 'subject:extra': 0.09; 'subject:string': 0.09; 'def': 0.12; '#this': 0.16; 'subject:when': 0.16; 'subject:python': 0.16; 'print': 0.22; 'skip:l 30': 0.24; 'skip:\xa0 20': 0.24; 'compare': 0.26; 'skip:" 30': 0.26; 'skip:" 20': 0.27; 'tried': 0.27; '8bit%:3': 0.30; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'lines': 0.31; 'skip:& 30': 0.33; 'subject:from': 0.34; 'received:google.com': 0.35; 'skip:f 40': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; '\xa0\xa0\xa0': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; '8bit%:47': 0.60; 'skip:n 30': 0.60; 'numbers': 0.61; 'first': 0.61; 'skip:n 10': 0.64; 'number:': 0.66; 'due': 0.66; 'between': 0.67; '8bit%:31': 0.68; '8bit%:100': 0.72; '"white': 0.84; '8bit%:49': 0.84; 'subject:space': 0.84; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.84; '"white': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=islrwng5mvlGCy98RiDyY7xvf2zQMY/P+y6Jl6q0CaU=; b=FfsnFmKYnBLfkBDurjY+7xrbcQm+m5RJ2tgYmjd9JiWL+kcpa2SFItowWHAkAXoU8z Ue0i7Fxa84EytAc5uWg2c9sjNVYW/f0+rpmVOVJDJe8e4bmKBH1BOS2otQBfVnw4C1wy broqZERwtld8xBeikL45leO6GFozpDqjjdHuOPl6MYPxci9DYqgrzmFJwoYHAM4TE0b4 Ybq0wIxk1f7WOqrvKXUFkHN9im/58VSfZHWhpLaSNUPlbLIf1TBM1svi4h6bKNiNf8Lo 9EHxjM2VsHUe0rtYZiNU1Zchk0lefMZgHYFJcGpn8An3088D9JFAN+YUE55Z/OFeZTI2 7zCA== MIME-Version: 1.0 X-Received: by 10.221.9.68 with SMTP id ov4mr6528148vcb.6.1372471636216; Fri, 28 Jun 2013 19:07:16 -0700 (PDT) Date: Fri, 28 Jun 2013 19:07:16 -0700 Subject: python adds an extra half space when reading from a string or list From: charles benoit To: python-list@python.org Content-Type: multipart/alternative; boundary=089e011778f557511804e04174bd X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 176 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372472409 news.xs4all.nl 15927 [2001:888:2000:d::a6]:36496 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49400 --089e011778f557511804e04174bd Content-Type: text/plain; charset=ISO-8859-1 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[b])<10: print(" "*(int(a[b])-space_count)),int(a[b]), space_count=int(a[b]) else: print(" "*(a[b]-space_count)),a[b], space_count=a[b]+1 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[b])<10: print(" "*(int(a[b])-space_count)),int(a[b]), space_count=int(a[b]) else: print(" "*(a[b]-space_count)),a[b], space_count=a[b]+1 this generates 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.# --089e011778f557511804e04174bd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: base64 PGRpdiBkaXI9Imx0ciI+PGRpdj48ZGl2PjxkaXY+PGJyPm51bWJlcl9kcmF3bj0oKTxicj5kZWYg bG9hZChsb3RfbnVtYmVyLG51bWJlcl9kcmF3bik6oCA8YnI+oKCgIGZpcnN0PWlucHV0KCZxdW90 O2VudGVyIGZpcnN0IGxvdDogJnF1b3Q7KTxicj6goKAgbGFzdD1pbnB1dCgmcXVvdDtlbnRlciBs YXN0IGxvdDogJnF1b3Q7KTxicj6goKAgZm9yIGxvdF9udW1iZXIgaW4gcmFuZ2UoZmlyc3QsbGFz dCk6PGJyPg0KoKCgoKCgoCBsaW5lX291dD1zdHIobG90X251bWJlcimgoKCgoKCgoKCgoCA8YnI+ oKCgoKCgoCBmb3IgY291bnQgaW4gcmFuZ2UoMSw1KTo8YnI+oKCgoKCgoKCgoKAgbnVtYmVyX2Ry YXduPXJhd19pbnB1dCgmcXVvdDtudW1iZXI6ICZxd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