Title 1 programming to realize the password guessing game, the requirements are as follows:

String (1) the preset abcdefghijklmnopqrstuvwxyz Passtr = “0123456789”.

(2) Write the password generating function code(STR,n) to randomly select 6 characters from the string STR to generate a 6-digit password.

(3) Call the code() function to generate a 6-digit password from the preset string

(4) The user enters the guessed password through the keyboard. If the password is correct, “Correct password” is displayed, and the program ends. If the password is incorrect, the system displays “Incorrect password. Re-enter the password for verification. (Preset 3 chances)

# 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=""# empty string for I in range(6): Pas += str[randint(0, Len (STR) -1)]# print(Pas)# print(Pas)# print(Pas)# print(Pas)# print(Pas)# print(Pas)# Guess=input(" Input password: ") if Guess==Pas: print(" password correct ") break else: print(" password incorrect, you still have {} chances ". Format (3-count)) print(" Game over! ") )Copy the code