Replace blanks with letter

eschneider92 at comcast.net eschneider92 at comcast.net
Tue Aug 20 04:35:05 EDT 2013


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



More information about the Python-list mailing list