Guest User

Untitled

a guest
Apr 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. for i in range(len(secretWord)):
  2. if secretWord[i] in correctLetters:
  3. blanks = blanks[:i] + secretWord[i] + blanks[i+1]
  4.  
  5. for i in range(len(secretWord)):
  6. if secretWord[i] in correctLetters:
  7. # blanks = the underscores from 0 to i found in blanks
  8. # + the secret letter at index i in secretWord
  9. # + the underscores from i+1 to the end found in blanks
  10. blanks = blanks[:i] + secretWord[i] + blanks[i+1:]
  11.  
  12. blanks = _____ (5 underscores)
  13. secretWord = Hi
  14.  
  15. lets assume that 'i' is in correct letters and 'h' is not
  16. (loop 2 times since len('hi') == 2)
  17. ------------------------------------------------------
  18. First iteration:
  19.  
  20. if 'h' in correctLetters (its not so skip):
  21. ------------------------------------------------------
  22. Second iteration:
  23.  
  24. 'i' is in correctLetters
  25.  
  26. blanks = __ (underscores from 0 to 1 in blanks)
  27. + 'i' (the letter at secretWord[1])
  28. + __ (blanks[2:onward] - the rest of the underscores ignoring the one where the letter goes)
  29.  
  30. for i in range(len(secretWord)):
  31. # i is index of secretword
  32. if secretWord[i] in correctLetters:
  33. # checking if letter secretWord[i] is in correctletters
  34. # if it is in, replace _ in blacks to secretWord[i]
  35. # recreate blank list by using everything before index i, secretWord[i], and everything after index i
  36. blanks = blanks[:i] + secretWord[i] + blanks[i+1]
Add Comment
Please, Sign In to add comment