list - Looping - python -


words = ['a', 'b', 'c', 'd'] code = ['3' , '2', '4' , '9'] 

i have 2 lists user must try , match together. in order this, have alter 'code' list:

number = input("enter number: ") letter = input("enter letter: ")  code =list(map(lambda x: str.replace(x, number, letter), code)) 

how can loop user has keep changing numbers 'code' list until matches 'words' list?

i've tried using

while code != words: 

but doesn't work because during second time, changes made first instance aren't present.

i think not reassigning user's guess (the lambda manipulation) proper code variable. i'm guessing through question, seems trying do:

words = ['a', 'b', 'c', 'd'] code = ['3' , '2', '4', '9']  while words != code:     number = raw_input("enter number: ")     letter = raw_input("enter letter: ")     code = list(map(lambda x: str.replace(x, number, letter), code))  print('you got it!') 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -