Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52732

Re: Replace blanks with letter

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'indices': 0.07; 'list).': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'spaces': 0.09; 'typed': 0.09; '"_"': 0.16; 'code?': 0.16; 'email addr:comcast.net': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'trying': 0.19; '(where': 0.19; 'header:User-Agent:1': 0.23; 'replace': 0.24; 'initial': 0.24; 'looks': 0.24; 'header:X-Complaints-To:1': 0.27; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; "skip:' 10": 0.31; 'subject:with': 0.35; 'add': 0.35; 'adjust': 0.36; 'doing': 0.36; 'should': 0.36; 'wrong': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'letters': 0.60; 'spot': 0.65; 'user,': 0.69; 'subject:letter': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Replace blanks with letter
Date Tue, 20 Aug 2013 11:19:31 +0200
Organization None
References <2bdbd16f-a676-4973-9866-db93b1b9cd9b@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084bcf2.dip0.t-ipconnect.de
User-Agent KNode/4.7.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.55.1376990390.19984.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1376990390 news.xs4all.nl 16006 [2001:888:2000:d::a6]:33839
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52732

Show key headers only | View raw


eschneider92@comcast.net wrote:

> I'm trying to replace the blank(_) with the letter typed in by the user,
> in the appropriate blank(_) spot where the letter should be (where is in
> the letters list).
> 
> letters='abcdefg'
> blanks='_ '*len(letters)
> print('type letter from a to g')
> print(blanks)
> input1=input()
> for i in range(len(letters)):
>     if letters[i] in input1:
>         blanks = blanks[:i] + letters[i] + blanks[i+1:]
> 
> 
> What am I doing wrong in this code?

`blanks` has two chars per letter in `letters`. If you change the initial 
value to

blanks = "_" * len(letters)

your code should work. If you think the output looks better with spaces you 
have to adjust the indices -- or you add spaces for printing only with

print(" ".join(blanks))

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Replace blanks with letter eschneider92@comcast.net - 2013-08-20 01:35 -0700
  Re: Replace blanks with letter Fábio Santos <fabiosantosart@gmail.com> - 2013-08-20 10:16 +0100
  Re: Replace blanks with letter Peter Otten <__peter__@web.de> - 2013-08-20 11:19 +0200
  Re: Replace blanks with letter eschneider92@comcast.net - 2013-08-20 13:45 -0700
    Re: Replace blanks with letter Dave Angel <davea@davea.name> - 2013-08-20 21:54 +0000
  Re: Replace blanks with letter eschneider92@comcast.net - 2013-08-21 00:49 -0700
    Re: Replace blanks with letter Chris Angelico <rosuav@gmail.com> - 2013-08-21 19:24 +1000
    Re: Replace blanks with letter Dave Angel <davea@davea.name> - 2013-08-21 11:42 +0000
    Re: Replace blanks with letter John Gordon <gordon@panix.com> - 2013-08-21 14:35 +0000
  Re: Replace blanks with letter eschneider92@comcast.net - 2013-08-22 15:42 -0700
    Re: Replace blanks with letter Dave Angel <davea@davea.name> - 2013-08-23 01:28 +0000
  Re: Replace blanks with letter eschneider92@comcast.net - 2013-08-22 15:44 -0700

csiph-web