Hey guys, I'm incredibly new to Python and even more so to its modules.
I have an excel file (names.xsxl) with 33 names and info. I'm trying to create a script that generates a random username as well as a password for each user in the 'E' and 'F' column respectively. How would I do this with the help of my two functions?
I hope I'm making myself clear, if I'm not, don't hesitate to ask for a clarification. Here's my code so far:
I have an excel file (names.xsxl) with 33 names and info. I'm trying to create a script that generates a random username as well as a password for each user in the 'E' and 'F' column respectively. How would I do this with the help of my two functions?
I hope I'm making myself clear, if I'm not, don't hesitate to ask for a clarification. Here's my code so far:
1 import random 2 import string 8 from openpyxl import workbook 9 from openpyxl import load_workbook 10 import xlrd 11 12 wb = load_workbook('names.xlsx') #reads the names.xlsx file 13 wb.save('names_mod.xlsx') #saves it with the name: names_mod.xslx 14 15 def randompassword(stringLength=8): #creates a random password 16 lettersAndDigits = string.ascii_letters + string.digits 17 return ''.join(random.choice(lettersAndDigits) for i in range(stringLength)) 18 19 def username(stringLength=5): #creates a random username 20 lettersAndDigits = string.ascii_letters + string.digits 21 return ''.join(random.choice(lettersAndDigits) for i in range(stringLength))Thankful for any help.