+ 1
While writing codes I tend to make mistakes and not notice it the I press enter and syntax error comes. I then select the entire code and press enter with the corrections but it tells me multiple statements syntax error what do I do?
5 Antworten
+ 2
As I understand the code has to generate a password between 8 to 16 characters long using letters, digits and symbols.
It actually worked on the app's console, but then I tried it on PC and it didn't. It might be due to different versions of python or software differences.
It's better to start the For cycles at the beginning of a line. And the join.() method is more used for connecting strings with a separator. I simply added them to one another. Try this, it worked for me on PC:
import string
from random import *
letters = string.ascii_letters
digits = string.digits
symbols = string.punctuation
chars = letters + digits + symbols
min_length = 8
max_length = 16
password = ""
for x in range(randint(min_length, max_length)):
password += choice(chars)
print(password)
+ 1
What's the exact code? It's hard to help without knowing the precise issue. There's a chance you didn't completely fix the errors.
+ 1
import string
from random import *
letters = string.ascii_letters
digits = string.digits
symbols = string.punctuation
chars = letters + digits + symbols
min_length = 8
max_length = 16
password = "".join(choice(chars) for x in range(randint(min_length, max_length)))
print(password)
0
This is the corrected one
0
Thanks Doc