mask - masking in python -


i'm attempting arrange following code digit representing character place in word appears below mask, in other words---

  _ _ _   1 2 3 

here's current code--

secretword = 'dog'  mask = '_'  * len(secretword) in range (len(secretword)):     if secretword[i] in correctletters:         mask = mask[:i] + secretword[i] + mask [i+1:] letter in mask:     print (letter, end='')   print () 

how go this?

a list representation out here:

secretword = list('dog') # ['d', 'o', 'g']  mask = ['_']  * len(secretword) # not problematic, since strs immutable i,char in enumerate(secretword):     if secretword[i] in correctletters:         mask[i] = secretword[i] print (''.join(mask)) 

hope helps


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -