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
Post a Comment