eschneide...@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)) -- http://mail.python.org/mailman/listinfo/python-list