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


Groups > comp.lang.python > #52727

Replace blanks with letter

X-Received by 10.224.127.70 with SMTP id f6mr2580070qas.5.1376987705864; Tue, 20 Aug 2013 01:35:05 -0700 (PDT)
X-Received by 10.49.101.5 with SMTP id fc5mr875qeb.25.1376987705796; Tue, 20 Aug 2013 01:35:05 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!fx3no3654174qab.0!news-out.google.com!c19ni379qak.0!nntp.google.com!fx3no3654168qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Tue, 20 Aug 2013 01:35:05 -0700 (PDT)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=68.38.30.68; posting-account=sLfkeQoAAAC9Lnlqp-6c6PVPFjrttJ3I
NNTP-Posting-Host 68.38.30.68
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <2bdbd16f-a676-4973-9866-db93b1b9cd9b@googlegroups.com> (permalink)
Subject Replace blanks with letter
From eschneider92@comcast.net
Injection-Date Tue, 20 Aug 2013 08:35:05 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:52727

Show key headers only | View raw


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?

Thanks
Eric

Back to comp.lang.python | Previous | NextNext 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