I need a python program for generating a random 8 digit numeric code and then send it to the email given by the user in a text box
Answers
Answered by
2
Answer:
# import library
import math, random
# function to generate OTP
def generateOTP() :
# Declare a digits variable
# which stores all digits
digits = "0123456789"
OTP = ""
# length of password can be chaged
# by changing value in range
for i in range(8) :
OTP += digits[math.floor(random.random() * 10)]
return OTP
# Driver code
if __name__ == "__main__" :
print("OTP of 8 digits:", generateOTP())
akshatjha89:
how do you create a text box in which the user enters his email and then the number generated is delivered to that email
e = Entry(master)
e.pack()
e.focus_set()
def callback():
print e.get() # This is the text you may want to use later
b = Button(master, text = "OK", width = 10, command = callback)
b.pack()
mainloop()
Similar questions