#'abcdefghijklmnopqrstuvwxyz0123456789'I am very new to Python or programing. I'm writing code for a password generator. I don't know how to make this line valid or part of the code with the #?
# issue
# issue
|
# indicates that everything after it on the same line is a comment and is ignored by the interpreter. The only exception is when it is at the very top of the script in which case it may actually be an instruction to the interpreter (e.g. shebang, define source code encoding)Show us your code in python tags and explain what exactly you want to do and what's going wrong. See BBcode help for more info.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs #password generator print("Hello, world!") import string import random while True: try length = int(input)('How long would you like your password to be?:' )) break except ValueError: print('value must be ') continue chars -string.ascii_letters + string.digits #'abcdefghijklmnopqrstuvwxyz0123456789 new_passsword = '' num = 0 while num < length num += 1 new_passsword+= random.choice(chars) print(new_passsword)This was one of our labs. These were my instructions. # Lab 8: Password Generator Let's generate a password of length n using a while loop and random.choice , this will be a string of random characters.## Advanced Allow the user to enter the value of n .[//]: # (show them the 'string builder pattern', how a string is build one character at a time)
line 14 should be
chars = string.ascii_letters + string.digitsthe comment is there just for that - to show/comment what chars would be. Normally one would put it on the previous line, e.g. chars = string.ascii_letters + string.digits # 'abcdefghijklmnopqrstuvwxyz0123456789Note that you have also problems with the indentation of the body of the while loop as well with the try/except. Try to fix these yourself
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs |
|
Users browsing this thread: 1 Guest(s)