python - using a while loop instead of for loop -
secret_word = "python" correct_word = "yo" count = 0  in secret_word:  if in correct_word:       print(i,end=" ")  else:       print('_',end=" ") so outcome of code _ y _ _ o _ question how can same output using while loop instead of using loop. know have use index iterate on each character when tried failed . help?
while count < len(secret_word):      if correct_word [count]in secret_word[count]:           print(correct_word,end=" ")      else:           print("_",end=" ")  count = count + 1 thanks
you can this:
secret_word = "python" correct_word = "yo" count = 0  while count < len(secret_word):     print(secret_word[count] if secret_word[count] in correct_word else '_', end=" ")     count += 1 
Comments
Post a Comment