Topic 1, programming, guess the password and implement, requirements are as follows: (1) the preset string abcdefghijklmnopqrstuvwxyz Passtr = “0123456789”. (2) Write the password generation function code(STR,n) ‘ ‘to randomly select 6 characters from the string STR to generate a 6-digit password. (3) The code() function is called to generate the 6-digit password from the preset string. (4) The user enters the guess password through the keyboard. If the password is entered correctly, “Password Correct” will be displayed to end the program. If the password is incorrectly entered, the display “Password error, reenter the password for verification. (Preset 3 opportunities)
# encoding = utf-8 mean * encoding = utf-8 encoding format for utf-8 format from the random import * Passtr string = "0123456789 abcdefghijklmnopqrstuvwxyz" # preset Def code(STR): # generate 6-bit password Pas=" Pas += str[randint(0, Print (pass) print(pass) print(pass) print(pass) print(pass) print(pass) print(pass) print(pass) print Guess==Pas: print(format(3-count)) break else: print(format(3-count)) print(" Game over! ") )